note 46639 added to function.preg-replace
| From: | gabe at mudbuginfo dot com | Date: | Mon, 18 Oct 2004 20:39:35 +0000 |
| Subject: | note 46639 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78735@lists.php.net to get a copy of this message | ||
It is useful to note that the 'limit' parameter, when used with 'pattern' and
'replace' which are arrays, applies to each individual pattern in the patterns array, and
not the entire array.
<?php
$pattern = array('/one/', '/two/');
$replace = array('uno', 'dos');
$subject = "test one, one two, one two three";
echo preg_replace($pattern, $replace, $subject, 1);
?>
If limit were applied to the whole array (which it isn't), it would return:
test uno, one two, one two three
However, in reality this will actually return:
test uno, one dos, one two three
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46639
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46639&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46639&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46639&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46639&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46639&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46639&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46639&report=yes
Search -- http://master.php.net/manage/user-notes.php