title: matching a word to end of string with strpos
body: <p><strong>Solution:</strong>
  <code>strpos</code> turned out to be the most efficient. Can be done with <code>substr</code> but that creates a temporary substring. Can also be done with regex, but slower than strpos and does not always produce the right answer if the word contains meta-characters (see Ayman Hourieh comment). </p>
  
  <p>Chosen answer:</p>
  
  <pre><code>if(strlen($str) - strlen($key) == strrpos($str,$key))
      print "$str ends in $key"; // prints Oh, hi O ends in O
  </code></pre>
  
  <p>and best to test for strict equality <code>===</code> (see David answer)</p>
  
  <p>Thanks to all for helping out. </p>
  
  <hr>
  
  <p>I'm trying to match a word in a string to see if it occurs at the end of that string. The usual <code>strpos($theString, $theWord);</code> wouldn't do that. </p>
  
  <p>Basically if <code>$theWord = "my word";</code></p>
  
  <pre><code>$theString = "hello myword";        //match
  $theString = "myword hello";        //not match
  $theString = "hey myword hello";    //not match
  </code></pre>
  
  <p>What would be the most efficient way to do it? </p>
  
  <p>P.S. In the title I said <code>strpos</code>, but if a better way exists, that's ok too.</p>