note 112451 added to function.preg-replace-callback
| From: | kkatpki | Date: | Tue, 18 Jun 2013 14:41:57 +0000 |
| Subject: | note 112451 added to function.preg-replace-callback | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195262@lists.php.net to get a copy of this message | ||
Note that, as of PHP 5.3, it seems that named subpatterns are now included in the matches array by
their named key as well as their numerical key.
To build off of Chris' previous example, as of PHP 5.3, you *can* do
<?php
preg_replace_callback('/(?<char>[a-z])/', 'callback', 'word');
function callback($matches) {
var_dump($matches);
}
?>
and expect to get $matches['char'] in your function. * BUT ONLY AS OF PHP 5.3 *
Please be mindful of this if you intend to support PHP 5.2.
----
Server IP: 69.147.83.199
Probable Submitter: 24.159.237.222
----
Manual Page -- http://php.net/manual/en/function.preg-replace-callback.php
Edit -- https://master.php.net/note/edit/112451
Del: integrated -- https://master.php.net/note/delete/112451/integrated
Del: useless -- https://master.php.net/note/delete/112451/useless
Del: bad code -- https://master.php.net/note/delete/112451/bad+code
Del: spam -- https://master.php.net/note/delete/112451/spam
Del: non-english -- https://master.php.net/note/delete/112451/non-english
Del: in docs -- https://master.php.net/note/delete/112451/in+docs
Del: other reasons-- https://master.php.net/note/delete/112451
Reject -- https://master.php.net/note/reject/112451
Search -- https://master.php.net/manage/user-notes.php