note 78395 added to function.preg-replace
| From: | djurredenboer at hotmail dot com | Date: | Wed, 10 Oct 2007 07:10:09 +0000 |
| Subject: | note 78395 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131267@lists.php.net to get a copy of this message | ||
I found something strange
<?php
$string = 'The quick brown fox jumped over the lazy dog.';
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements[2] = 'bear';
$replacements[1] = 'black';
$replacements[0] = 'slow';
echo preg_replace($patterns, $replacements, $string);
?>
Output The bear black slow jumped over the lazy dog.
But when you swap the replacements like
$replacements[0] = 'slow';
$replacements[2] = 'bear';
$replacements[1] = 'black';
you get The slow bear black jumped over the lazy dog.
----
Server IP: 83.137.20.107
Probable Submitter: 213.84.213.133
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/78395
Del: integrated -- https://master.php.net/note/delete/78395/integrated
Del: useless -- https://master.php.net/note/delete/78395/useless
Del: bad code -- https://master.php.net/note/delete/78395/bad+code
Del: spam -- https://master.php.net/note/delete/78395/spam
Del: non-english -- https://master.php.net/note/delete/78395/non-english
Del: in docs -- https://master.php.net/note/delete/78395/in+docs
Del: other reasons-- https://master.php.net/note/delete/78395
Reject -- https://master.php.net/note/reject/78395
Search -- https://master.php.net/manage/user-notes.php