ID: 25234 Updated by: [EMAIL PROTECTED] Reported By: info at sima-pc dot com -Status: Open +Status: Bogus Bug Type: Strings related Operating System: WIN98 PHP Version: 4.3.1 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is expected behaviour. Previous Comments: ------------------------------------------------------------------------ [2003-08-25 06:27:55] info at sima-pc dot com Description: ------------ It's not exactly a bug but I believe str_replace has a problem that can be solved. In the first sample below, after replacing "ONE" with "TWO WORDS", process follows with next array item and it changes "TWO" with "MANY LETTERS". After the first successful replacement, shouldn't it stop replacing? IMHO it will be the right function flow. Thanks, David Gimeno i Ayuso Reproduce code: --------------- <?php $match=array("ONE","TWO","THREE"); $replace=array("TWO WORDS","MANY LETTERS","OTHER IDEAS"); $sample="ONE SAMPLE"; echo "first=",str_replace($match,$replace,$sample); $match=array("TWO","ONE","THREE"); $replace=array("MANY LETTERS","TWO WORDS","OTHER IDEAS"); $sample="ONE SAMPLE"; echo "second=",str_replace($match,$replace,$sample); ?> Expected result: ---------------- first=TWO WORDS SAMPLE second=TWO WORDS SAMPLE Actual result: -------------- first=MANY LETTERS WORDS SAMPLE second=TWO WORDS SAMPLE ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25234&edit=1