You could replace the longer one, "Blueberry", first. Then, the only
remaining occurrences of "Blue" will be ones that you really want.

Kirk

> I am performing a str_replace() on a large string, and 
> everything works 
> fine, except that two of the elements I'm searching for (and 
> replacing) 
> have the same first letters. To keep it the issue clear, here's a 
> simple example of what I'm talking about:
> 
> Blue
> Blueberry
> 
> Now, if I use:
> 
> str_replace("Blue","Red",$paragraph);
> str_replace("Blueberry","Strawberry",$paragraph);
> 
> 
> ...all occurrences of Blue—including Blueberry—will be replaced with 
> Red. The result will be something like:
> 
> Red
> Redberry
> 
> ...But what I want is...
> 
> Red
> Strawberry

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

Reply via email to