how are you doing it for only the FIRST???

Anyhoo, a simple string replace should do it... I'd do this:

$result = str_replace($search,"<span
class=\"highlight\">{$search}</span>",$result);

Justin


on 04/11/02 6:27 PM, David Russell ([EMAIL PROTECTED]) wrote:

> Hi there,
> 
> My brain has just gone very fuzzy...
> 
> I have a search string ($search) and a result ($result). I need to
> highlight every occurance of $search in $result.
> 
> I know that it means that I need to change (for example)
> 
> $result = "This is a test, isn't it?"
> $search = "is"
> 
> Into 
> 
> $result = "th<span class="highlight">is</span> <span
> class="highlight">is</span> a test, <span class="highlight">is</span>'nt
> it"
> 
> Now I can easily see how to change the FIRST occurrence of the word, but
> how can I change every occurance?
> 
> Thanks
> 
> 
> 
> David Russell
> IT Support Manager
> Barloworld Optimus (Pty) Ltd
> Tel: +2711 444-7250
> Fax: +2711 444-7256
> e-mail: [EMAIL PROTECTED]
> web: www.BarloworldOptimus.com
> 


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

Reply via email to