hey, I need a little help...
I'm making a search engine, and I want all the words that are found in the pages of search results to be highlighted (css text background hightlight). That part is easy. Just eregi_replace the search words with highlighted text in the database content.
Now, if your still following me, let's say someone searches for "b" (yes, "b") and (since I have some HTML in my database) it will hightlight the HTML tag <B>
Therefore, messing the whole page up because PHP altered some of the original database HTML. I can't understand how to get it NOT to highlight the search text if it is in an HTML tag.
Any ideas? I'm currently using this code, which doesn't seem to work:
$formatted = eregi_replace("(($word[$i])(%[<(.)>]%)*)","<FONT STYLE=\"background-color:#749BC0\">\1</FONT>",$formatted);
The above highlights the text, but it also highlights the HTML tags and messed up everything.
Bottom Line: I'm trying to highlight certain words from my database content without having PHP highlight the HTML tags.