note 66883 added to function.str-ireplace
| From: | sugus at noware dot net | Date: | Wed, 31 May 2006 13:20:42 +0000 |
| Subject: | note 66883 added to function.str-ireplace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112641@lists.php.net to get a copy of this message | ||
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"...
----
Server IP: 212.124.37.9
Probable Submitter: 195.190.92.190
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.str-ireplace.php
Edit -- http://master.php.net/note/edit/66883
Del: integrated -- http://master.php.net/note/delete/66883/integrated
Del: useless -- http://master.php.net/note/delete/66883/useless
Del: bad code -- http://master.php.net/note/delete/66883/bad+code
Del: spam -- http://master.php.net/note/delete/66883/spam
Del: non-english -- http://master.php.net/note/delete/66883/non-english
Del: in docs -- http://master.php.net/note/delete/66883/in+docs
Del: other reasons-- http://master.php.net/note/delete/66883
Reject -- http://master.php.net/note/reject/66883
Search -- http://master.php.net/manage/user-notes.php