Find the last occurrence of "php" in a string:
<?phpecho strrpos("I love php, I love php too!","php");?>The strrpos() function finds the last occurrence of a string within another string (case sensitive).
Note: The strrpos() function is case-sensitive.
Related functions:
strpos() - finds the first occurrence of a string within another string (case sensitive)
stripos() - Finds the first occurrence of a string within another string (case insensitive)
strripos() - Finds the last occurrence of a string within another string (case insensitive)
strrpos( string,find,start )
parameter | describe |
---|---|
string | Required. Specifies the string to be searched for. |
find | Required. Specifies the characters to search for. |
start | Optional. Specifies the location to start the search. |
Return value: | Returns the position of the last occurrence of a string within another string, or FALSE if the string is not found. Note: The string position starts from 0, not from 1. |
---|---|
PHP version: | 4+ |
Update log: | Since PHP 5.0, the find parameter can be a string of more than one character. In PHP 5.0, the start parameter is added. |