For highlighting without the overhead of regex and without destroying capitalization, try this:
<?php
function highlight($needle, $haystack){
$ind = stripos($haystack, $needle);
$len = strlen($needle);
if($ind !== false){
return substr($haystack, 0, $ind) . "<b>" . substr($haystack, $ind, $len) . "</b>" .
highlight($needle, substr($haystack, $ind + $len));
} else return $haystack;
}
?>
This example uses HTML bold tags, but you can easily change the highlighting method.