PHP strripos() Function

Definition

The strripos() function finds the position of the last occurrence of a string inside another string. The strripos() function is case-insensitive.

Syntax

PHP strripos() Function has the following syntax.

strripos(string,find,start)

Parameter

ParameterIs RequiredDescription
stringRequired.String to search
findRequired.String to find
startOptional.Where to begin the search

Return

PHP strripos() Function returns the position of the last occurrence of a string inside another string, or FALSE if the string is not found.

String positions start at 0, and not 1.

  • stripos() - Finds the position of the first occurrence of a string inside another string (case-insensitive)
  • strpos() - Finds the position of the first occurrence of a string inside another string (case-sensitive)
  • strrpos() - Finds the position of the last occurrence of a string inside another string (case-sensitive)

Example

Find the position of the last occurrence of "php" inside the string:


<?php
echo strripos("php from java2s.com","PHP");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions