strpos function in reverse in php

Taps101 picture Taps101 · Oct 21, 2012 · Viewed 34.9k times · Source

strpos function in reverse

I would like to find a method where i can find a character position in reverse.For example last "e" starting count in reverse.

From example

$string="Kelley";
$strposition = strpos($string, 'e');

it will give me position 1.

Answer

Manuel Schweigert picture Manuel Schweigert · Oct 21, 2012
int strrpos ( string $haystack , string $needle [, int $offset = 0 ] )

Find the numeric position of the last occurrence of needle in the haystack string.

http://php.net/manual/en/function.strrpos.php