note 82306 deleted from function.array-merge by salathe
| From: | salathe@php.net | Date: | Mon, 06 Sep 2021 22:47:23 +0000 |
| Subject: | note 82306 deleted from function.array-merge by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216914@lists.php.net to get a copy of this message | ||
Note Submitter: bishop
----
The documentation is a touch misleading when it says: "If only one array is given and the array
is numerically indexed, the keys get reindexed in a continuous way." Even with two arrays, the
resulting array is re-indexed:
[bishop@predator staging]$ cat array_merge.php
<?php
$a = array (23 => 'Hello', '42' => 'World');
$a = array_merge(array (0 => 'I say, '), $a);
var_dump($a);
?>
[bishop@predator staging]$ php-5.2.5 array_merge.php
array(3) {
[0]=>
string(7) "I say, "
[1]=>
string(5) "Hello"
[2]=>
string(5) "World"
}
[bishop@predator staging]$ php-4.4.7 array_merge.php
array(3) {
[0]=>
string(7) "I say, "
[1]=>
string(5) "Hello"
[2]=>
string(5) "World"
}