I'm looking to get the same exact results as php strstr command (while it set to true) but in reverse order.
I know that I can simply reverse the string and use strstr and then reverse it again
but I was wonder if there is any internal php command for the task.
<?php
$myString = 'We don\'t need no education';
echo strstr($myString, ' ', true);
/*
* output :
* We
*
* I'm expecting to get :
* education
*
*/
exit;
?>
Very Simple !
You have the function strrchr
$myString = 'We don\'t need no education';
echo strrchr($myString, ' ');
// output : ' education'
echo substr(strrchr($myString, ' '), 1);
// output : 'education'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With