Giving a search term a yellow background color

itstroandoz

New Member
The function below puts a search term \[code\]$find\[/code\] in bold. It works just fine. However, I would like to make it so that instead of putting \[code\]$find\[/code\] in bold, it gives it a yellow background, as in the CSS property \[code\]background-color:#FFFF00;\[/code\]. How could I do this?Thanks in advance,JohnThe function:\[code\]function highlight($text, $words) { preg_match_all('~\w+~', $words, $m); if(!$m) return $text; $re = '~\\b(' . implode('|', $m[0]) . ')\\b~i'; return preg_replace($re, '<b>$0</b>', $text);}\[/code\]The PHP/HTML:\[code\]echo '<td class="sitename1search"><a href="http://www...com>'.highlight($row["title"], $find)).'</a></td>';\[/code\]The CSS:\[code\].sitename1search { width: 800px; font-family: Arial, Helvetica, sans-serif; font-weight: normal; font-size: 12px; overflow:hidden !important; color: #000000; padding-bottom: 0px;}.sitename1search a{ width: 350px; font-family: Arial, Helvetica, sans-serif; font-weight: normal; font-size: 12px; overflow:hidden !important; color: #004284; padding-bottom: 0px;}\[/code\]
 
Back
Top