Re: Array merge changes VALUE of keys, never mind the type

From: Date: Fri, 28 Sep 2001 17:59:47 +0000
Subject: Re: Array merge changes VALUE of keys, never mind the type
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-66776@lists.php.net to get a copy of this message
Andrei wrote: > array_merge() does *not* change the value of keys. Period. Sigh, yes it does. And below is the simple proof. <? // -*- c -*- $arr1 = array(1=>'one'); $arr2 = array(2=>'two'); print_r(array_merge($arr1, $arr2)); ?> gives: Array ( [0] => one [1] => two ) Please tell me in what way this hasn't changed the keys. Derrick and your response andrei are very disappointing. Nick On Fri, Sep 28, 2001 at 06:35:22PM +0100, Nick Lindridge wrote: > Hi, > > Regarding what seems an array merge bug. This was > quickly made bogus (:-), but I think that the > point was missed. The issue isn't that the key > was made numeric - I had it numeric and not a string > in the first place. The issue is that the key value > was changed. > > The array element key values had a meaning - otherwise > I wouldn't have bothered by using keys at all. > > array_merge should not change the value of keys. It should > just merge! If not a bug, it is a flaw. > > Nick

« previous php.dev (#66776) next »