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"...
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|