note 51010 deleted from function.str-replace by bjori
| From: | bjori@php.net | Date: | Sun, 26 Mar 2006 22:24:51 +0000 |
| Subject: | note 51010 deleted from function.str-replace by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106673@lists.php.net to get a copy of this message | ||
Note Submitter: Gabriel Wärmby
----
Note that when using the str_replace function it will always replace the already replaced parts in a
String even if you just allow replacement of one character at a time.
[php]
$thecode = '453461';
for ($t=0; $t<=5; $t++){
$index = substr($thecode,$t,1);
$digits = array(1, 2, 3, 4, 5, 6);
$newdigits = array(4, 5, 2, 7, 8, 0);
$realcode.= str_replace($digits, $newdigits, $index);
}
/*Would print out '782707' instead of '7827704' as it should with this
construction.*/
echo $realcode;
[/php]