strrpos

int strrpos(string string, string character) 

Finds the last position at which a character occurs within a string.

Returns:

Integer; FALSE if the character cannot be found in the string

Description:

strrpos() returns the position of the last occurrence of character within string .

If character is not found, the function returns FALSE.

If the character parameter is not a string, it’s converted to an integer. The resulting integer is used as the ordinal value of a character.

Version:

PHP 3+, PHP 4+

See also:

Other functions that find characters within strings:

substr() 
strchr() 
stristr() 
strpos() 
strstr() 

Example:

Search for the last “a” in an aphorism
<?php 
$text = "It's darkest before the dawn."; 
echo strrpos ($text, 'a'); 
?> 

Output: ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.