Re: [PROPOSAL]Add second to callback of preg_replace_callback
| From: | Xinchen Hui | Date: | Mon, 29 Apr 2013 17:20:07 +0000 |
| Subject: | Re: [PROPOSAL]Add second to callback of preg_replace_callback | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67201@lists.php.net to get a copy of this message | ||
发自我的 iPad
在 2013-4-30,1:09,Remi Collet <remi@fedoraproject.org> 写道:
> Le 29/04/2013 18:46, Laruence a écrit :
>
>> so I propose to add a second argument to callback(aim to php-5.5.1),
>
> Seems a useful fix to this problem (also encounter elsewhere)
>
>> what do you think(of course, the second argument can also easily change
>> to be the regex idx in the regex array)?
>
> I will prefer the idx (regex can be really long and complex string, and
> a minor change to a regex need to be also applied in the callback)
Yeah, I used regex just because it is easier to make a quick patch.
Using index need more functions signature changed
Will make that patch tomorrow
Thanks
>
> Esp if you can use a more simpler / meaningful value
>
> Ex:
>
> $code = preg_replace_callback(
> array(
> "foo" => "/some very complex regex/",
> "bar" => "/another one/",
> ...
> ),
> function($matches, $idx) {
> switch ($idx) {
> case 'foo'
> ...
> case 'bar':
> ...
> }
> },
> $code);
>
>
> My 0,02�
>
> Remi.
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>