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
[EMAIL PROTECTED] 
_______________________________ 
  BackendMedia 
  www.backendmedia.com 
  [EMAIL PROTECTED] 

  Linn Zwoch Smith GbR 
  Pariser Str. 44 
  D-10707 Berlin 

  Tel +49 30 83 22 50 00 
  Fax +49 30 83 22 50 07

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to