I have this function:
function boldWord($string, $keyWord) {
$kWordArray = split("[ +.-|&%]", $keyWord);
$clr = "#3399ff";
while(list(, $kWord) = each($kWordArray)) {
if($kWord != "") {
$kWord = rawurlencode($kWord);
$string = str_replace($kWord, "<b><font color=\"$clr\">$kWord</font></b>", $string);
$string = str_replace(strtoupper($kWord), "<b><font color=\"$clr\">" . strtoupper($kWord) . "</font></b>", $string);
$string = str_replace(strtolower($kWord), "<b><font color=\"$clr\">" . strtolower($kWord) . "</font></b>", $string);
$string = str_replace(ucfirst($kWord), "<b><font color=\"$clr\">" . ucfirst($kWord) . "</font></b>", $string);
}
}
return $string;
}
The function is working fine. But it doesn't operate correctly whenever it is used to process a string containing characters such as apostophies. I.e. email addresses. What is wrong???