Home >>PHP String Functions >PHP strripos() Function
PHP strripos() function is used to find the position of the last occurrence of a specified string inside another string. This function is case-insensitive. It returns an integer value which is the position of the last occurrence of the specified string.
Syntax:
strripos($string, $find, $start);
Parameter | Description |
---|---|
string | This is a required parameter. This parameter defines the string to be searched. |
find | This is a required parameter. This parameter defines the string to find. |
start | This is an optional parameter. This parameter defines where to begin the search. |
Here is an example of strripos() function in PHP:
<html> <body> <?php echo strripos("PHP is a server side scripting language. PHP stands for Hypertext Pre-processor.","PHP"); ?> </body> </html>
Here is an another example of strripos() function in PHP:
<html> <body> <?php $string = "PHP, Java, Python, JavaScript, PHP Framework, PHPTPOINT"; $search = "php"; $position = strripos($string, $search, 5); if ($position == true){ echo "Found at position " . $position; } else{ echo "Not Found"; } echo "<br> <br>"; $position = strripos($string, $search, 47); if ($position == true){ echo "Found at position " . $position; } else{ echo "Not Found"; } ?> </body> </html>