Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP String strripos() function returns the index number of last occurrence of the specified text in the given string. Unlike strrpos function, it is not a case-sensitive function.

Note: The strripos() function is not a case-sensitive function.

Syntax

strripos(string, find, start)

Parameters

string Required. Specify the string to search.
find Required. Specify the string to find.
start Optional. Specify the index number from where the search need to start.

Return Value

Returns the index number of last occurrence of specified text in the given string.

Example:

In the below example, strripos() function is used to find the index number of last occurrence of "be" in the given string called MyString.

<?php
$MyString = "To be, or not to be, that is the question.";

echo strripos($MyString, "be")."\n";
?>

The output of the above code will be:

17

Example:

In the below example, last occurrence of "be" is searched after the specified strating position.

<?php
$MyString = "To be, or not to be, that is the question.";

echo strripos($MyString, "be", 5)."\n";
?>

The output of the above code will be:

17

❮ PHP String functions