note 35244 added to function.str-replace
| From: | David at rack1 dot php dot net | Date: | Mon, 25 Aug 2003 11:12:49 +0000 |
| Subject: | note 35244 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55027@lists.php.net to get a copy of this message | ||
Take care with order when using arrays in replacement.
$match=array("ONE","TWO","THREE");
$replace=array("TWO WORDS","MANY LETTERS","OTHER IDEAS");
$sample="ONE SAMPLE";
echo str_replace($match,$replace,$sample);
It will show: "MANY LETTERS WORDS SAMPLE"
That is, after replacing "ONE" with "TWO WORDS", process follows with next array
item and it changes "TWO" with "MANY LETTERS".
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35244
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35244&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35244&report=yes