Re: PHP 4.0 Bug #4875: array_merge() is unable to merge arrays with numeric keys

From: Date: Wed, 07 Jun 2000 19:20:27 +0000
Subject: Re: PHP 4.0 Bug #4875: array_merge() is unable to merge arrays with numeric keys
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-20493@lists.php.net to get a copy of this message
On Wed, Jun 07, 2000 at 01:05:34PM -0500, Andrei Zmievski wrote: > On Wed, 07 Jun 2000, waldschrott@kiffen.de wrote: > > From: waldschrott@kiffen.de > > Operating system: all > > PHP version: 4.0.0 Release > > PHP Bug Type: Feature/Change Request > > Bug description: array_merge() is unable to merge arrays with numeric keys > > > > array_merge() is unable to merge arrays with numeric keys (as described in the > > documentation), however that´s usefull sometimes and should be possible, in face of the fact that > > even casting the keys to (string) they´re saved as (int)s. > > Please describe in more detail how you want arrays with numeric keys to > be merged. Here's an example: $a = array("a"=>"a"); $b = array("1"=>"b"); $c = array_merge($a, $b); while(list($k,$v)=each($c)) echo "$k:$v\n"; gives a:a 0:b but would be nice if got a:a 1:b when 1 is a string. The problem is not with array_merge, but with arrays in general I think. It seems that a numeric string like "1" is treated as an index and not a key. Would be nice if there was a difference, but fixing it might break a lot of existing PHP code I guess. Stig

« previous php.dev (#20493) next »