note 123435 added to function.array-merge
| From: | NicolasA@php.net | Date: | Fri, 14 Dec 2018 09:53:45 +0000 |
| Subject: | note 123435 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209898@lists.php.net to get a copy of this message | ||
Beware:
$arr1 = [
'1' => 'a',
'2' => 'b'
];
$arr2 = [
'5' => 'c',
'6' => 'd'
];
$arr3 = array_merge($arr1, $arr2);
Here, arr3 will contain
$arr3 = [
0 => 'a',
1 => 'b',
2 => 'c',
3 => 'd'
]
Despite all keys being strings. The fact that they can be casted as integers is enough for
array_merge
----
Server IP: 208.43.231.9
Probable Submitter: 2a01:cb10:d:6c00:2c6f:a85a:80b1:da07
----
Manual Page -- http://php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/123435
Del: integrated -- https://master.php.net/note/delete/123435/integrated
Del: useless -- https://master.php.net/note/delete/123435/useless
Del: bad code -- https://master.php.net/note/delete/123435/bad+code
Del: spam -- https://master.php.net/note/delete/123435/spam
Del: non-english -- https://master.php.net/note/delete/123435/non-english
Del: in docs -- https://master.php.net/note/delete/123435/in+docs
Del: other reasons-- https://master.php.net/note/delete/123435
Reject -- https://master.php.net/note/reject/123435
Search -- https://master.php.net/manage/user-notes.php