Keys Are Integers Whenever Possible¶
<?php
$array = [];
$array["01000"] = "Bourg-en-Bresse";
$array["75001"] = "Paris";
var_dump($array);
Array keys are only strings or integers: the later has priority. So, when storing a string that can be converted to an integer, PHP does the conversion automatically.
In the case displayed, the keys are French zip codes, which might start with a leading 0. But PHP converts it into integer, and drops that leading 0. The value is still correctly indexed, but now, the string representation has changed.
See Also¶
PHP Features¶
Last updated: 14 July 2026