Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80320 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52950 invoked from network); 10 Jan 2015 11:53:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2015 11:53:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.171 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.171 mail-wi0-f171.google.com Received: from [209.85.212.171] ([209.85.212.171:34996] helo=mail-wi0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/30-48183-5C211B45 for ; Sat, 10 Jan 2015 06:53:42 -0500 Received: by mail-wi0-f171.google.com with SMTP id bs8so6814813wib.4 for ; Sat, 10 Jan 2015 03:53: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=npQB8fAFSxWNaPGkvgsayfiKhL+N1UIWhyTquIspnhY=; b=tqDbW66Hy48JZkyJQro5FWrBE2cgaALf1AvghANGpyF5IYsnZ1tpD/9f8Ty54ko7Qc Ua0TtRmvOx6YQWKb/NCYwEPHpZIvQ4gWTfg7GsWHn/38fR/gth4/YsvT7Czz/mzxwECw 8tRX/fOOBjz2VxrXV1p3m9/NcYtxc3o+LyuIqq7w7Y7QYpSN/VJ9dUL6jdIxtMilYEZn eWwLx7eIxwI+MZ4Lpfw7XWHMTrMa9AHlBGE3TX7v9AF8nol4F2An20y1A/piPLlVUbVv Dy8B1LeaLIC9l6AZluScs3e4oOiVDsQUMehgPNpThvXCQQAIG+bEjNemHB1GGP6XM6bp byzQ== MIME-Version: 1.0 X-Received: by 10.194.79.226 with SMTP id m2mr12855009wjx.60.1420890818143; Sat, 10 Jan 2015 03:53:38 -0800 (PST) Received: by 10.27.10.196 with HTTP; Sat, 10 Jan 2015 03:53:38 -0800 (PST) In-Reply-To: <007801d02ba0$659b9080$30d2b180$@tekwire.net> References: <003e01d0290b$2387dd30$6a979790$@yahoo.fr> <007801d02ba0$659b9080$30d2b180$@tekwire.net> Date: Sat, 10 Jan 2015 12:53:38 +0100 Message-ID: To: francois@tekwire.net Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7bf0c5387aec6c050c4aeca8 Subject: Re: [PHP-DEV] [BugFest] Feature request #38685: str_[i]replace(): Add support for (string needle, array replace) From: nikita.ppv@gmail.com (Nikita Popov) --047d7bf0c5387aec6c050c4aeca8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Jan 9, 2015 at 1:08 AM, Fran=C3=A7ois Laupretre wrote: > Hi, > > I just created the RFC : > > https://wiki.php.net/rfc/cyclic-replace > > I tried to include everything we agreed upon. Tell me if I missed > something. > > Please note that the current PR does not implement the whole RFC. You may > review the RFC while I update the code. > > Please also give me your opinion about implementing a similar feature in > preg_replace() and preg_filter(). > When submitting an RFC, please open a separate thread. Otherwise people who do not follow every single discussion will not see it. I'm against this RFC. Not because I don't like the implementation or similar, I simply don't consider this functionality to be sufficiently important to warrant both the additional internal complexity it adds and the complexity it adds to our user-facing API. str_replace is a simple function for string replacement. It has some (imho also unnecessary) extra gimmicks to implicitly do a foreach() loop during the replacement. This is still relatively simple API-wise. But if I see this (taken from the tests) as the search & replacement values... $search=3Darray('[?]',array('(?)','d','e'),'a','R'); $repl=3Darray( array('ap(?)z[?]',"b[?](?)v",null,37,"[?]n[?]"), array('a',array('b',null)), array('k(?)j[?]') ); ... I have a pretty hard time figuring out what this is actually supposed to do. At this point str_replace is working on arbitrarily-nested arrays and also has four options to control its behavior. Imho this is just too much complexity for a relatively minor use case. Nikita --047d7bf0c5387aec6c050c4aeca8--