How to use strrchr() function to find the last occurrence of a character in string with PHP

2 Answers

0 votes
// string strrchr(string $haystack, mixed $needle)

$s = "Luke the Skywalker and Yoda the Jedi";

echo strrchr($s, 'e');


/*
run:
    
edi 
    
*/

 



answered Jul 20, 2016 by avibootz
0 votes
// string strrchr(string $haystack, mixed $needle)

$s = "Luke the\n Skywalker\n and\n Yoda the Jedi";

echo strrchr($s, 10); // \n = 10 ascii



/*
run:
    
Yoda the Jedi 
    
*/

 



answered Jul 20, 2016 by avibootz
...