Bug #52852 [NEW]: array_merge modifies numerical keys even if non-numerical
| From: | fh-phpbug2 at fholzhauer dot de | Date: | Wed, 15 Sep 2010 10:15:41 +0000 |
| Subject: | Bug #52852 [NEW]: array_merge modifies numerical keys even if non-numerical | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-5049@lists.php.net to get a copy of this message | ||
From:
Operating system: osx
PHP version: 5.3.3
Package: Documentation problem
Bug Type: Bug
Bug description:array_merge modifies numerical keys even if non-numerical
Description:
------------
Not sure if this a documentation problem or a function problem, but either
way, it is a bug :-)
The documentation for array_merge says "If all of the arrays contain only
numeric keys, the resulting array is given incrementing keys starting from
zero."
However, integer keys are always renumbered even if there is a non-numeric
key present.
Test script:
---------------
<?php
$test = array('foo' => false, 1=>2.34, 2=>13.12);
var_dump($test);
$result = array_merge(array(),$test);
var_dump($result);
Expected result:
----------------
array(3) {
["foo"]=>
bool(false)
[1]=>
float(2.34)
[2]=>
float(13.12)
}
array(3) {
["foo"]=>
bool(false)
[1]=>
float(2.34)
[2]=>
float(13.12)
}
Actual result:
--------------
array(3) {
["foo"]=>
bool(false)
[1]=>
float(2.34)
[2]=>
float(13.12)
}
array(3) {
["foo"]=>
bool(false)
[0]=>
float(2.34)
[1]=>
float(13.12)
}
--
Edit bug report at http://bugs.php.net/bug.php?id=52852&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52852&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52852&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52852&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52852&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52852&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52852&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52852&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52852&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52852&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52852&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52852&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52852&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52852&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52852&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52852&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52852&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52852&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52852&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52852&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52852&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52852&r=mysqlcfg