Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:4650 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15210 invoked by uid 1010); 2 Oct 2003 11:06:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15154 invoked from network); 2 Oct 2003 11:06:58 -0000 Received: from unknown (HELO mail.dybnet.de) (195.75.116.242) by pb1.pair.com with SMTP; 2 Oct 2003 11:06:58 -0000 Received: (qmail 17376 invoked by uid 508); 2 Oct 2003 11:04:45 -0000 Received: from unknown (HELO vandal) (vandal@212.202.39.136) by www.dybnet.de with RC4-MD5 encrypted SMTP; 2 Oct 2003 11:04:45 -0000 To: Date: Thu, 2 Oct 2003 13:05:59 +0200 Organization: BackendMedia GbR Message-ID: <003301c388d5$29b7f880$4d00a8c0@vandal> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal Subject: array_merge_clobber From: smith@backendmedia.com ("Lukas Smith") Hi, Ok here is another patch written by my new intern (Ralf Willenbacher) which adds array_merge_clobber to the set of array functions. After a bit of pondering we think that array_merge_replace might be a better name for it. But that is just sugar on top once we agree on the principal. Note: array_merge_clobber behaves a bit different than array_merge and array_merge_recursive and different than array addition. array array_merge_clobber ( array array1, array array2 [, array ...]) Essentially it does the following: It copies the first array and then overwrites any values that have the same key (numeric or string) or appends any values that have a key that is not yet defined by working recursively over the subsequent arrays. So values in array 2 overwrite values in array 1 that have the same key (numeric or string). And values in array 3 overwrite values in array 2 that have the same key (numeric or string). Etc. You can find the path here: http://www.backendmedia.com/php_patches/mergeclobber.patch Here is a little test script (with the implementation I made in PHP): http://www.backendmedia.com/php_patches/array_merge_clobber.php While working on this patch we found a bug in array_merge_recursive. But I will submit this in a separate mail. Regards, Lukas Smith smith@backendmedia.com _______________________________ BackendMedia www.backendmedia.com berlin@backendmedia.com Linn Zwoch Smith GbR Pariser Str. 44 D-10707 Berlin Tel +49 30 83 22 50 00 Fax +49 30 83 22 50 07