Heya all,

I'm trying to highlight search keywords in a string, everything work expect
when this keyword is inside a tag like this :

keyword (php) :

<a href="?go=php">php</a>

<img src="php.gif" border=0 alt="php.net">

will be highlighted to :

<a href="?go=<b style="color: black; background-color: #ffff66">php</b>"><b
style="color: black; background-color: #ffff66">php</b></a>

<img src="<b style="color: black; background-color: #ffff66">php</b>.gif"
border=0 alt="<b style="color: black; background-color:
#ffff66">php</b>.net">

I have tryed to separate text from html, then highlight it then join
html/text again, but this will be very long and not really usefull !

I'm using preg_replace :

preg_replace('|\b('.quotemeta($keyword).')\b|iU', '<b style="color: black;
background-color: #ffff66">\\1</b>', $content);

Any help to fix that ?

Thanks;
Hatem


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to