Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64337 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60391 invoked from network); 18 Dec 2012 12:08:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Dec 2012 12:08:55 -0000 Authentication-Results: pb1.pair.com header.from=neufeind@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=neufeind@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 91.184.32.3 as permitted sender) X-PHP-List-Original-Sender: neufeind@php.net X-Host-Fingerprint: 91.184.32.3 mail.speedpartner.de Received: from [91.184.32.3] ([91.184.32.3:41284] helo=mail.speedpartner.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/B7-33799-6DC50D05 for ; Tue, 18 Dec 2012 07:08:55 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.speedpartner.de (Postfix) with ESMTP id 66F9A61F09 for ; Tue, 18 Dec 2012 13:08:47 +0100 (CET) Received: from mail.speedpartner.de ([127.0.0.1]) by localhost (mail.speedpartner.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8dn16y1f6LOb for ; Tue, 18 Dec 2012 13:08:47 +0100 (CET) Received: from collab.speedpartner.de (collab.speedpartner.de [91.184.32.10]) by mail.speedpartner.de (Postfix) with ESMTP id 4EFB760C34 for ; Tue, 18 Dec 2012 13:08:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by collab.speedpartner.de (Postfix) with ESMTP id D0457CE1874 for ; Tue, 18 Dec 2012 13:08:47 +0100 (CET) X-Virus-Scanned: amavisd-new at collab.speedpartner.de Received: from collab.speedpartner.de ([127.0.0.1]) by localhost (collab.speedpartner.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M9iYDwmFaug5 for ; Tue, 18 Dec 2012 13:08:46 +0100 (CET) Received: from [192.168.4.20] (ip-62-143-17-30.unitymediagroup.de [62.143.17.30]) by collab.speedpartner.de (Postfix) with ESMTPSA id B1F80CE186E for ; Tue, 18 Dec 2012 13:08:46 +0100 (CET) Message-ID: <50D05CD0.8080206@php.net> Date: Tue, 18 Dec 2012 13:08:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: php-dev Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Extension for str_replace / preg_replace with arrays From: neufeind@php.net (Stefan Neufeind) Hi, inside a framework-/scripting-project we've lately discussed string-replacements with arrays. Currently PHP supports either replacing one string by another or replacing first element from one array with first from another array. What I'd like to propose is for str_replace and preg_replace to introduce: * a functionality to replace one string with strings from an array * to (optionally) allow for rolling replacements (1,2,3, 1,2,3, ...) * to (optionally) allow to skip strings already replaced (that means not to accidentially double-replace strings) This would allow to do things like $content = str_replace('
  • ', array('
  • ', '
  • ', '
  • '), $content); optionally starting over from A again. (Current default is to stop when there are no more elements to replace with). Would such a change/extension find support? Kind regards, Stefan Neufeind