note 66883 deleted from function.str-ireplace by bjori
| From: | bjori@php.net | Date: | Wed, 31 May 2006 14:34:39 +0000 |
| Subject: | note 66883 deleted from function.str-ireplace by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-112649@lists.php.net to get a copy of this message | ||
Note Submitter: sugus at noware dot net
Reason: in docs
----
Attention if you are using the array feature:
Search and replace won't stop after the first hit in the serach-array.
Look at this example:
$codeword = "WZ-ERMXR-XLWV";
$from = str_split('ABCDEFGHIJKLMZYXWVUTSRQPON');
$to = str_split('ZYXWVUTSRQPONABCDEFGHIJKLM');
echo str_replace($from,$to,$codeword);
It was expected to result as "DA-VINCI-CODE"
but it returned "WZ-ERMXR-XLWV"
The "W" was found to be the first element in $from and replaced with "D", then
the comparision went on and found "D" again as an element on $from, which was then
replaced by "W"...