Re: [PROPOSAL]Add second to callback of preg_replace_callback

From: Date: Mon, 29 Apr 2013 17:07:29 +0000
Subject: Re: [PROPOSAL]Add second to callback of preg_replace_callback
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
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)

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.



Thread (22 messages)

« previous php.internals (#67200) next »