Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39226 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7478 invoked from network); 23 Jul 2008 13:44:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2008 13:44:46 -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.153 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.235.152.153 mail963c35.nsolutionszone.com Linux 2.5 (sometimes 2.4) (4) Received: from [209.235.152.153] ([209.235.152.153:56404] helo=mail963c35.nsolutionszone.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/61-12534-CC537884 for ; Wed, 23 Jul 2008 09:44:45 -0400 X-POP-User: wilmascam.centurytel.net Received: from pc1 (d13-125.rt-bras.pell.centurytel.net [69.179.187.125]) by mail963c35.nsolutionszone.com (8.13.6.20060614/8.13.1) with SMTP id m6NDiaRv021767; Wed, 23 Jul 2008 13:44:38 GMT Message-ID: <014401c8ecca$4047b7d0$0201a8c0@pc1> To: , "Christian Schneider" References: <01b401c8ec13$28cd3510$0201a8c0@pc1> <18.5D.12534.2EF17884@pb1.pair.com> Date: Wed, 23 Jul 2008 08:44:00 -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: Re: [PHP-DEV] Re: [PATCH] New functions: array_replace[_recursive] From: php_lists@realplain.com ("Matt Wilmas") Hi Christian, ----- Original Message ----- From: "Christian Schneider" Sent: Wednesday, July 23, 2008 > Matt Wilmas wrote: > > array_replace() is like the + operator applied to arrays, except that it > > WILL overwrite ("replace") existing entries. > > Excuse my ignorance but what's the difference between > $array = array_replace($array1, $array2); > and > $array = $array2 + $array1; > apart from different order of the entries in the resulting array? The order of the entries is the only difference, I believe. :-) I think that's desirable however, and having the non-recursive version makes it match array_merge(), etc. As for bloat or something, there's virtually no extra code: only PHP_FUNCTION() and then in the wrapper function it just uses zend_hash_merge() just like the + operator, except with its "overwrite" param set to 1. > > 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. > > Hmm, generic enough to be included? What Lukas said. :-) > - Chris - Matt