I'm trying to match a word in a string to see if it occurs at the end of that string. The usual strpos($theString, $theWord);
wouldn't do that.
Basically if $theWord = "my word";
$theString = "hello myword"; //match
$theString = "myword hello"; //not match
$theString = "hey myword hello"; //not match
What would be the most efficient way to do it?
P.S. In the title I said strpos
, but if a better way exists, that's ok too.
$word = "foo";
then both$sentence = "barfoo" or "bar foo";
should stillmatch
. It's not important in this case if it has a space before it or not. – Ligamentous