I have this PHP code to highlight the Query on search results.
if (isset($_REQUEST['k'])){
$k = htmlentities($_REQUEST['k']);
$position = 0;
while ($position = stripos($text, $k, ($position)?$position+30:0) and $position !== false){
$text = substr_replace($text, '</span>', $position + strlen($k), 0 );
$text = substr_replace($text, '<span class="highlight">', $position, 0);
}
}
The problem is that if I search something like “cafe”, there might be results with “café” (é) and that terms won’t be highlighted…
How can I fix this?
Thanks!
here is a link that includes a normalization array and several examples of what I think you are trying to acheive – https://www.php.net/strtr