Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67200 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33422 invoked from network); 29 Apr 2013 17:08:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2013 17:08:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=remi@fedoraproject.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=remi@fedoraproject.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fedoraproject.org from 212.27.42.5 cause and error) X-PHP-List-Original-Sender: remi@fedoraproject.org X-Host-Fingerprint: 212.27.42.5 smtp5-g21.free.fr Linux 2.6 Received: from [212.27.42.5] ([212.27.42.5:52285] helo=smtp5-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/02-23191-DE8AE715 for ; Mon, 29 Apr 2013 13:08:24 -0400 Received: from dixsept.famillecollet.com (unknown [82.241.130.121]) by smtp5-g21.free.fr (Postfix) with ESMTP id BA7EAD48218 for ; Mon, 29 Apr 2013 19:07:30 +0200 (CEST) Message-ID: <517EA8D1.2000108@fedoraproject.org> Date: Mon, 29 Apr 2013 19:07:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130403 Thunderbird/17.0.5 MIME-Version: 1.0 To: PHP Internals References: In-Reply-To: X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [PROPOSAL]Add second to callback of preg_replace_callback From: remi@fedoraproject.org (Remi Collet) 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.