Home > Article > Backend Development > PHP function strripos() to find the last occurrence of a string in another string (case insensitive)
Example
Find the last occurrence of "php" in a string:
<?php echo strripos("I love php, I love php too!","PHP"); ?>
Definition and usage
strripos() function finds the last occurrence of a string in another string The position of the last occurrence in the string (case-insensitive).
Note: The strripos() function is not case-sensitive.
Related functions:
stripos() - Find the first occurrence of a string in another string (case-insensitive)
strpos() - Find the first occurrence of a string in another string (case sensitive)
strrpos() - Find a character The position of the last occurrence of a string in another string (case sensitive)
Syntax
strripos(string,find,start)
Parameters | Description |
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. |
Technical details
Return value: | Returns a string within another string The position of the last occurrence, or FALSE if the string is not found. Note: The string position starts from 0, not from 1. |
PHP version: | 5+ |
Change log: | Since PHP 5.0, find The argument can be a string of more than one character. In PHP 5.0, the start parameter is added. |
Example
Find the last occurrence of "java" in the string:
<?php echo strripos("what is java and what is php?","java"); ?>
The above is the detailed content of PHP function strripos() to find the last occurrence of a string in another string (case insensitive). For more information, please follow other related articles on the PHP Chinese website!