Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39195 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74009 invoked from network); 22 Jul 2008 15:54:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jul 2008 15:54:07 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 209.235.152.150 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.235.152.150 mail960c35.nsolutionszone.com Linux 2.5 (sometimes 2.4) (4) Received: from [209.235.152.150] ([209.235.152.150:53739] helo=mail960c35.nsolutionszone.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/01-02156-D9206884 for ; Tue, 22 Jul 2008 11:54:06 -0400 X-POP-User: wilmascam.centurytel.net Received: from pc1 (d13-125.rt-bras.pell.centurytel.net [69.179.187.125]) by mail960c35.nsolutionszone.com (8.13.6.20060614/8.13.1) with SMTP id m6MFrxQT032708; Tue, 22 Jul 2008 15:54:00 GMT Message-ID: <01b401c8ec13$28cd3510$0201a8c0@pc1> To: Cc: "Lukas Kahwe Smith" Date: Tue, 22 Jul 2008 10:52:28 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 Subject: [PATCH] New functions: array_replace[_recursive] From: php_lists@realplain.com ("Matt Wilmas") Hi all, Adding these two array functions has been on the TODO for a while, and my original patch has been collecting dust for almost 2 years. :-) I just updated the patches now after some small changes (the original version for 5.2 is currently linked on the wiki). A brief description, if I remember correctly, especially the recursive version (Lukas can maybe give more info. since he created the original implementation in PHP ;-)): array_replace() is like the + operator applied to arrays, except that it WILL overwrite ("replace") existing entries. array_replace_recursive() will do the same except that it becomes recursive only when both the destination and source entries are arrays, otherwise the new source entry still replaces any existing one. In the wrapper function, I removed the SEPARATE_ZVAL() and convert_to_array_ex() as they appear to be leftover from PHP 4 (before array_merge[_recursive] checked if the args were arrays first). This made a big performance difference when I benchmarked 2 years ago! I also updated it to use array_init_size() (returned array will have at least as many elements as the largest input array) for another small optimization. http://realplain.com/php/array_replace.diff http://realplain.com/php/array_replace_5_3.diff (With NEWS entry) http://realplain.com/php/array_replace.phpt (Still has the old UEXPECT section for HEAD; will fix if I commit) Any thoughts or objections? Should I commit before Thursday, like tomorrow...? Thanks, Matt