#42323 [NEW]: Details in array_merge page are wrong
| From: | kev at projectcolo dot org dot uk | Date: | Thu, 16 Aug 2007 22:36:17 +0000 |
| Subject: | #42323 [NEW]: Details in array_merge page are wrong | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969377481@lists.php.net to get a copy of this message | ||
From: kev at projectcolo dot org dot uk
Operating system: N/A
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Details in array_merge page are wrong
Description:
------------
The notes in Example 257 above are incorrect. It states:
If you want to completely preserve the arrays and just want to append them
to each other, use the + operator
Check the array type page at
http://www.php.net/manual/en/language.types.array.php
which states
differently. Duplicate keys are ignored with the + operator.
Reproduce code:
---------------
<?php
$x = array('moon','sky');
$y = array('rain','shine');
var_dump($x + $y);
var_dump(array_merge($x, $y));
?>
Expected result:
----------------
array(2) {
[0]=>
string(4) "moon"
[1]=>
string(3) "sky"
... more values
}
array(4) {
[0]=>
string(4) "moon"
[1]=>
string(3) "sky"
[2]=>
string(4) "rain"
[3]=>
string(5) "shine"
}
Actual result:
--------------
array(2) {
[0]=>
string(4) "moon"
[1]=>
string(3) "sky"
}
array(4) {
[0]=>
string(4) "moon"
[1]=>
string(3) "sky"
[2]=>
string(4) "rain"
[3]=>
string(5) "shine"
}
--
Edit bug report at http://bugs.php.net/?id=42323&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42323&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42323&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42323&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42323&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42323&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42323&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42323&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42323&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42323&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42323&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42323&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42323&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42323&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42323&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42323&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42323&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42323&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42323&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42323&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42323&r=mysqlcfg