Hello, i have a search engine. And i want to make a highlight for each word in the result list which match with the keyword that specified in the form. could someone here give me a script which can do what i need Kind regards
Dunno about the script part - but you can define the highlight section in a css file, and then in PHP simply define the highlight part when the phrase match occurs. cheers GS
// Keywords that the user used $keywords = array('i', 'want', 'to', 'find', 'it'); $keywords = array_filter(array_unique($keywords)); $keywords = array_map('preg_quote', $keywords); // $text = the search result text $text = preg_replace('~(' . $implode('|', $keywords) . ')~i', '<span class="keyword">$1</span>', $text); PHP: Now define a CSS class called "keyword" with the properties you want and you're done.