PHP » Strings » strrpos()

Syntax:
int strpos(string s, string search [, int offset])
s
String to search in.
search
Character sequence to search for.

Returns the position of the last occurrence of a substring.

strrpos() returns the position of the last occurrence of a string within another string. The optional offset is available in versions 5 and above. Positive offsets are counted from the beginning of the string and negative offsets are counted from the end of the string. If no occurrence is found, FALSE is returned.

Examples

Code:
<?php

print 'Position of last occurrence of "hello": ' . strrpos("hello world hello", "hello") . "<br>";

?>
Output:
Position of last occurrence of "hello": 12
Explanation:

strrpos() is used to find the last occurrence of a word.

See Also: