You will need to break apart the entire document then process each area
inside of the
tags and to be very careful for nested tags.

The simplest way around I have found to do with is to add to tags that
have been processed
with attributes that are ignored by the browser renderer eg... <a
href="/page.html" done="yes">PHP</a>
as you can see the <a href has been processed because I have added in a
extra attribute then continue
to process the entire page from my preg matches.

Nested tags are going to be your biggest issue.



Timothy Hitchens (HiTCHO)
Open Platform Consulting
e-mail: [EMAIL PROTECTED]

> -----Original Message-----
> From: Hatem Ben [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, 12 January 2003 7:24 PM
> To: PHP List
> Subject: [PHP] highlight keywords issue
> 
> 
> 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
> 


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

Reply via email to