I have a seacrch engine that searches articles on my website. I want to be able to highlight the words the user has searched for.
Sounds easy up to yet...
$content = preg_replace('/' . $search_term . '/i', "<font color=\"red\"><b>" . $search_term . "</b></font>", $content);
BUT my articles contain HTML, so, if someone, for example, searched for "color", or "href", it would corrupt all of my layout.
Is there any way around this?
Also, is there anyway, for example, if someone types in "php is good" it would highlight each indevidual word?
Thanks
Jonathan