The rindex() function returns the position (integer offset) of the last occurence of a substring Returns -1 if the substring cannot be found $myString = "Hello World"; $val = rindex( $myString, "o" ); # Yields 7 $val = rindex( $myString, "x" ); # Yields -1 You may also specify an offset from which to start the search $myString = "Hello World"; $val = rindex( $myString, "o", 6 ); # Yields 4
$val = rindex( $myString, "x" ); # Yields -1