Bug #18075: array_merge() redefines numeric keys

From: Date: Sun, 30 Jun 2002 20:14:23 +0000
Subject: Bug #18075: array_merge() redefines numeric keys
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12597@lists.php.net to get a copy of this message
From: nepto@pobox.sk Operating system: Linux, FreeBSD PHP version: 4.1.2 PHP Bug Type: Arrays related Bug description: array_merge() redefines numeric keys Lets consider that we have following arrays, $ar1 and $ar2: // first array $ar1 = array(); $ar1[1] = 'val1'; $ar1[2] = 'val2'; // second array $ar2 = array('key' => ''); Than we have resulting array $res. Let's lookwhat happend after array_merge() call: $res = array_merge($ar1, $ar2); var_dump($res); Resulting array is described here: array(3) { [0]=> string(4) "val1" [1]=> string(4) "val2" ["key"]=> string(0) "" } Numeric keys 1 and 2 was recoded to 0 and 1. Looks like bug, isn't it? I refer to the documentation, but there is nothing written about the numeric keys redefining. An exaple there (in documentation) shows example, where only numeric keys started from 0 are used, so no such change happened. -- Edit bug report at http://bugs.php.net/?id=18075&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18075&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18075&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18075&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18075&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18075&r=support Expected behavior: http://bugs.php.net/fix.php?id=18075&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18075&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18075&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18075&r=globals

« previous php.bugs (#12597) next »