note 35244 deleted from function.str-replace by googleguy
| From: | googleguy@php.net | Date: | Sat, 19 Jan 2013 03:42:49 +0000 |
| Subject: | note 35244 deleted from function.str-replace by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193227@lists.php.net to get a copy of this message | ||
Note Submitter: David Gimeno i Ayuso (info at sima-pc dot com)
----
Take care with order when using arrays in replacement.
<?php
$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".