Just change the order and do the "search and replace" on "Blueberry" before doing it 
on "Blue."

Ei:

str_replace("Blueberry","Strawberry",$paragraph);
str_replace("Blue","Red",$paragraph);

or:

str_replace(array("Blueberry", "Blue"), array("Strawberry", "Red"), $paragraph);

_________________________________________________
Marcus Rasmussen
[EMAIL PROTECTED]
www.marcusr.dk

-------------------------------------------------------------
On 31-03-2003 at 13:52 René Fournier wrote:
-------------------------------------------------------------

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

  I need str_replace to somehow only search for a complete occurrence of
each item. How do I do that? I've read the docs, and I just can't see
any examples.

Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


--
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