If someone searches by "ender" and the title of the item is "Henderson", this function should return:
H<span class="mark">ender</span>son
Somehow it is not working when i call mark_match("Henderson","ender");
Any ideas? This is the function that takes the original item title and compares it to the search string:
function mark_match($txt,$s) {
# Remove unwanted data
$txt = strip_tags($txt);
# Remove innecesary spaces
$txt = preg_replace('/\s+/',' ', $txt);
# Mark keywords
$replace = '<span class="mark">\\1</span>';
foreach($s as $sitem) {
$pattern = '/('.trim($sitem).')/i';
$txt = preg_replace($pattern,$replace,$txt);
}
return $txt;
}