note 49221 deleted from function.array-merge by salathe
| From: | salathe@php.net | Date: | Mon, 06 Sep 2021 22:47:37 +0000 |
| Subject: | note 49221 deleted from function.array-merge by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216911@lists.php.net to get a copy of this message | ||
Note Submitter: Alec Solway
----
Note that if you put a number as a key in an array, it is eventually converted to an int even if you
cast it to a string or put it in quotes.
That is:
$arr["0"] = "Test";
var_dump( key($arr) );
will output int(0).
This is important to note when merging because array_merge will append values with a clashing
int-based index instead of replacing them. This kept me tied up for hours.