Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67201 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35156 invoked from network); 29 Apr 2013 17:20:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2013 17:20:11 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.169 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.217.169 mail-lb0-f169.google.com Received: from [209.85.217.169] ([209.85.217.169:46497] helo=mail-lb0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/62-23191-9CBAE715 for ; Mon, 29 Apr 2013 13:20:10 -0400 Received: by mail-lb0-f169.google.com with SMTP id z5so1215308lbh.28 for ; Mon, 29 Apr 2013 10:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:references:from:mime-version:in-reply-to:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=0xhKiNW8+1Q49n2cexs60bAhSB2F6AWctIfDfbCyc6o=; b=GzYFFRIbi3yr8ySaXhupO4O7EE7IRF8mwDybrIXSwVVuRuAqYc8HULhU9ir6w0DWl+ Qldze4cr2QCJzOoxtrVxJ5V4JvDnWxNICZw2nsraENJyx/sTtylD7v5oZTT5IWqgvXcu mVWGq3D8rgZsL2MF/hqjgf010YwswCZhd0M6JJreYUIeDJ4qSrTD0b6ziBKcrDOxcgV/ KhAk13fjnI/BmPia2W5kOkiZYf4k+swdBEJkBPLX6ybduvQSV7rtFk6ACA8X8ToQhhMK 7mbCwLGDTD/EucuFJj/idR2HA6Ff6jcByfeLDvUKZZ6NoPHa2tOBedgNv/esy3gCLZ8U S8OA== X-Received: by 10.152.28.130 with SMTP id b2mr27668121lah.51.1367256006516; Mon, 29 Apr 2013 10:20:06 -0700 (PDT) References: <14729498.29703.1367255350466.JavaMail.mobile-sync@ieboh2> Mime-Version: 1.0 (1.0) In-Reply-To: <14729498.29703.1367255350466.JavaMail.mobile-sync@ieboh2> Date: Tue, 30 Apr 2013 01:20:07 +0800 Message-ID: <745363686559186914@unknownmsgid> To: Remi Collet Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [PROPOSAL]Add second to callback of preg_replace_callback From: laruence@gmail.com (Xinchen Hui) =E5=8F=91=E8=87=AA=E6=88=91=E7=9A=84 iPad =E5=9C=A8 2013-4-30=EF=BC=8C1:09=EF=BC=8CRemi Collet =E5=86=99=E9=81=93=EF=BC=9A > Le 29/04/2013 18:46, Laruence a =C3=A9crit : > >> 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 =3D preg_replace_callback( > array( > "foo" =3D> "/some very complex regex/", > "bar" =3D> "/another one/", > ... > ), > function($matches, $idx) { > switch ($idx) { > case 'foo' > ... > case 'bar': > ... > } > }, > $code); > > > My 0,02=EF=BF=BD > > Remi. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >