Doc #51699 [Opn->Csd]: array_merge() reindexes multiple arrays - doc error
| From: | salathe@php.net | Date: | Fri, 30 Apr 2010 12:30:02 +0000 |
| Subject: | Doc #51699 [Opn->Csd]: array_merge() reindexes multiple arrays - doc error | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4283@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51699&edit=1
ID: 51699
Updated by: salathe@php.net
Reported by: stevenrusch at gmail dot com
Summary: array_merge() reindexes multiple arrays - doc error
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: WinXp
PHP Version: Irrelevant
-Assigned To:
+Assigned To: salathe
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
That sentence has been rephrased to read, "If all of the arrays contain
only
numeric keys, the resulting array is given incrementing keys starting
from zero."
Hopefully that makes more sense; please give feedback if not. Thank you
for your
report.
Previous Comments:
------------------------------------------------------------------------
[2010-04-30 14:27:38] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=298804
Log: clarify array_merge reindexing behaviour with numeric-only keys
(bug #51699)
------------------------------------------------------------------------
[2010-04-30 01:41:39] stevenrusch at gmail dot com
Description:
------------
The 3rd paragraph of documentation description states:
"If only one array is given and the array is numerically indexed, the
keys get reindexed in a continuous way."
The "If only one array is given" is incorrect. I supplied two arrays,
both numerically indexed, and the result was reindexed (as also shown in
Example#3). The sentence implies this would not happen if multiple
numerically indexed arrays were given because it says "if only one...".
The documentation should state: "If one or more arrays are given in
which all arrays contain only numeric keys, the array values are merged
and the keys are reindexed starting with zero in a continuous way." or
something to that effect.
I realize Example #3 somewhat shows this by supplying two arrays one of
which is empty and it shows the reindex. It would still be nice if the
wording in the description above matched this. As you guessed, I read
the doc description, used it, debugged my problem, and THEN noticed
Example #3.
Test script:
---------------
$array1 = array(10=>'Ten',11=>'eleven');
$array2 = array(5=>'five',16=>'sixteen');
var_dump(array_merge($array1,$array2));
Expected result:
----------------
array(4) { [10]=> string(3) "Ten"
[11]=> string(6) "eleven"
[5]=> string(4) "five"
[16]=> string(7) "sixteen" }
Actual result:
--------------
array(4) { [0]=> string(3) "Ten"
[1]=> string(6) "eleven"
[2]=> string(4) "five"
[3]=> string(7) "sixteen" }
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51699&edit=1