Re: Re: Bug #12480 Updated: array_merge_recursive() clobbers existing numeric keys

From: Date: Mon, 06 Aug 2001 18:02:07 +0000
Subject: Re: Re: Bug #12480 Updated: array_merge_recursive() clobbers existing numeric keys
References: 1 2 3 4 5  Groups: php.dev 
Request: Send a blank email to php-dev+get-62329@lists.php.net to get a copy of this message
On Mon, 06 Aug 2001, Peter Lowe wrote: > I agree, you *should* preserve all elements of the input array in the > output one, one of those elements being the key. > > it actually says on the man page: > > If, however, the arrays have the same numeric key, the later > value will not overwrite the original value, but will be appended. > > if the values get appended, why renumber numeric keys from 0? What would you have them start with? :) Imagine this scenario: $array1 = array('a', 'b', 'c'); $array2 = array(2=>'d', 3=>'e', 4=>'f'); $result = array_merge($array1, $array2); In this case, $result is: Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f ) What should it look like according to you? -Andrei We all have photographic memories, it's just that some of us don't have any film.

« previous php.dev (#62329) next »