Finds the last occurrence of a string inside a string.

Arguments Edit

void strrpos ({{{params}}})

Argument Inclusion Edit

  • strrpos needs PHP version 4 or 5 to work.

Return values Edit

strrpos will return the numeric position of the last search string inside the given string. Note that the position in string starts with 0 and not with 1. If the optional offset parameter was set it starts searching at the character with that number. The return value will still be relative to the beginning of the string.

Examples Edit

Example 1: The direct way Edit

 echo strrpos("Find a string inside a string", "string");

Output Edit


Example 2: Using a variable and offset Edit

 $string = "abc abc abc";
 $find   = "a";
 echo strrpos($string, $find, 1); // Stars searching at the first b

Output Edit

For more details on this function, visit its entry in the php manual.