How do you detect if a specific word is at the end of a string in php -
i have event listings this
papa roach @ paramount in huntington on apr 28, 2015 im trying remove after last "on"
$s="papa roach @ paramount in huntington on apr 28, 2015"; echo strstr($s, 'on', true); i came removes after first "on" detects, there way run backwards or tell skip last "on"
you can use strrpos function perform search end of string:
$s="papa roach on paramount in huntington on apr 28, 2015"; echo substr($s, 0, strrpos($s, ' on ') + 3); // +3 include word on
Comments
Post a Comment