note 46639 deleted from function.preg-replace by cmb
| From: | cmb@php.net | Date: | Sun, 29 Sep 2019 07:18:18 +0000 |
| Subject: | note 46639 deleted from function.preg-replace by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212391@lists.php.net to get a copy of this message | ||
Note Submitter: gabe at mudbuginfo dot com
----
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