List Info

Thread: note 66883 added to function.str-ireplace




note 66883 added to function.str-ireplace
user name
2006-05-31 13:20:42
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.p
hp.net/note/edit/66883
Del: integrated  -- ht
tp://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://m
aster.php.net/note/delete/66883/spam
Del: non-english -- h
ttp://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://ma
ster.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

note 66883 deleted from function.str-ireplace by bjori
user name
2006-05-31 14:34:39
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

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )