case insensitive highlighting in php
Posted
by fusion
on Stack Overflow
See other posts from Stack Overflow
or by fusion
Published on 2010-05-01T16:44:48Z
Indexed on
2010/05/01
17:57 UTC
Read the original article
Hit count: 156
i'm using this function to highlight the results from mysql query:
function highlightWords($string, $word)
{
$string = str_replace($word, "<span class='highlight'>".$word."</span>", $string);
/*** return the highlighted string ***/
return $string;
}
....
$cQuote = highlightWords(htmlspecialchars($row['cQuotes']), $search_result);
the problem is, if i type in 'good', it will only show my search results with a lower-case 'g'ood and not 'Good'. how do i rectify this?
© Stack Overflow or respective owner