i\'m using this code to highlight search keywords:
function highlightWords($string, $word)
{
$string = str_replace($word, \"
I've used the regex written before and replaced \w with [A-Za-z0-9_äöüÄÖÜ]. As you see I added the umlauts äöüÄÖÜ.
I also have removed the \b so it will match any appearance of the search term.
search term:
Su shamp
text:
Sun shiny shampoo
result:
Sun shiny shampoo
private function getSearchTermToBold($text, $words)
{
preg_match_all('~[A-Za-z0-9_äöüÄÖÜ]+~', $words, $m);
if (!$m)
return $text;
$re = '~(' . implode('|', $m[0]) . ')~i';
return preg_replace($re, '$0', $text);
}