I was testing the strrchr function and was baffled by its behaviors. It is supposed to return the substring from the last occurrence of the matching pattern. For instance,
$test = 'example@hotmail.com';
echo strrchr($test,'@') ;
this returns the substring from the “@”, that is @hotmail.com, but if I search for this “hot”
$test = 'example@hotmail.com';
echo strrchr($test,'example') ;
instead of tmail.com (I expected), how come it returns hotmail.com, and if I search for other patterns, the results are strange too. Thank you
Only first character is used for searching, based on php documentation:
see: http://php.net/manual/en/function.strrchr.php