Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80191 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50584 invoked from network); 5 Jan 2015 18:06:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2015 18:06:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.172 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:56461] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/F5-21693-1B2DAA45 for ; Mon, 05 Jan 2015 13:06:42 -0500 Received: by mail-we0-f172.google.com with SMTP id k11so8304883wes.3 for ; Mon, 05 Jan 2015 10:06:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=C2/2V7I3qwecMq/KbvExbUSivzYb+b5aNYSIaXQ6Zf0=; b=PRLBAH8i/yjDv9bYUZpIS5ecgOkAVkRYASjfJ9E2uTcTg2gQ/z5yxJJxxw3ET8SSLU /48L7ogZhl9hXIno7vvxxQHk5u95nDJookY7NIFU6IK/6ZSLGUOnycaPQyhSd/2qGKaw dSYr9TK/5rxw0v0kyuaZfG6BCyiHGp4rj9tT9W4nqcH3bknMyS+rpi48vbvJygu1+MHc QnD5cWwtZWz9VJJlTEnnw8gEfFUMGgAd92ubF+yB/2LY6a/4W8wrJJqhkacIakNzV0t5 BeEmFk8UE1ZmLSp+3QSz5rh34Olc93xNSAx7XvVp8n8VwrT1Piz95KgWzrXl1rObvdpt P5YA== MIME-Version: 1.0 X-Received: by 10.180.98.138 with SMTP id ei10mr28401314wib.32.1420481198360; Mon, 05 Jan 2015 10:06:38 -0800 (PST) Received: by 10.180.88.33 with HTTP; Mon, 5 Jan 2015 10:06:38 -0800 (PST) In-Reply-To: References: <003e01d0290b$2387dd30$6a979790$@yahoo.fr> Date: Mon, 5 Jan 2015 19:06:38 +0100 Message-ID: To: Andrea Faulds Cc: nf.laupretre@yahoo.fr, PHP Internals Content-Type: multipart/alternative; boundary=f46d044267fe3d115c050beb8db3 Subject: Re: [PHP-DEV] [BugFest] Feature request #38685: str_[i]replace(): Add support for (string needle, array replace) From: tyra3l@gmail.com (Ferenc Kovacs) --f46d044267fe3d115c050beb8db3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Jan 5, 2015 at 6:20 PM, Andrea Faulds wrote: > Hey Fran=C3=A7ois, > > > On 5 Jan 2015, at 17:15, F & N Laupretre wrote: > > > > I just created a PR for a feature request lying around since 2006 : > > > > https://github.com/php/php-src/pull/980 > > > > It adds support in str_replace() and str_ireplace() for the combination > of > > (string needle, array replace). In this case, each occurrence of the > needle > > is replaced with an element f the 'replace' array, looping if > count(replace) > > is lower than count(needles) in subject. It is interesting for cyclic > > replacements (alternating line colors, for instance). The PR includes t= he > > needed tests. > > This would have been really useful for me quite recently, I was > disappointed to see it doesn=E2=80=99t already work. Please go ahead with= this! > > Thanks. > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > usually each BC break would warrant an RFC and a vote, but I'm not sure many people would use str_replace("foo", array("bar"), $subject); and expect the implicit array to string conversion of array("bar") =3D> "Array" which also emits a notice. let's see what others think. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --f46d044267fe3d115c050beb8db3--