note 92961 deleted from function.array-merge by cmb
| From: | cmb@php.net | Date: | Sun, 29 Sep 2019 07:29:44 +0000 |
| Subject: | note 92961 deleted from function.array-merge by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212397@lists.php.net to get a copy of this message | ||
Note Submitter: Julian Egelstaff
----
More about the union operator (+)...
The "array_unique" that gets applied, is actually based on the keys, not the values. So
if you have multiple values with the same key, only the last one will be preserved.
<?php
$array1[0] = "zero";
$array1[1] = "one";
$array2[0] = 0;
$array1[1] = 1;
$array3 = $array1 + $array2;
// array3 will look like:
// array(0=>0, 1=>1)
// ie: beware of the latter keys overwriting the former keys
?>