Searching strings IN strings with preg
<p>If someone searches by "ender" and the title of the item is "Henderson", this function should return:</p>

<pre><code>H&lt;span class="mark"&gt;ender&lt;/span&gt;son
</code></pre>

<p>Somehow it is not working when i call mark_match("Henderson","ender");</p>

<p>Any ideas? This is the function that takes the original item title and compares it to the search string:</p>

<pre><code>function mark_match($txt,$s) {
 # Remove unwanted data
 $txt = strip_tags($txt);
 # Remove innecesary spaces
 $txt = preg_replace('/\s+/',' ', $txt);
 # Mark keywords
 $replace = '&lt;span class="mark"&gt;\\1&lt;/span&gt;';
 foreach($s as $sitem) {
  $pattern = '/('.trim($sitem).')/i';
  $txt = preg_replace($pattern,$replace,$txt); 
 }
 return $txt;
}
</code></pre>
