note 67686 deleted from language.types.array by googleguy
| From: | googleguy@php.net | Date: | Thu, 17 Jan 2013 22:28:27 +0000 |
| Subject: | note 67686 deleted from language.types.array by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193190@lists.php.net to get a copy of this message | ||
Note Submitter: ch dot martin at gmail dot com
----
Extremely irritating quirk regarding the variable types of array keys:
<?php
$r = array('05' => "abc", '35' => "def");
foreach ($r as $key=>$value)
var_dump($key);
?>
The first var_dump for '05' is:
string(2) "05"
as expected. But the second, '35', turns out as:
int(35)
Php apparently decided to make the 35 became an int, but not the 05 (presumably because it leads
with a zero). As far as I can see, there is absolutely no way of making string(2) "35" an
array key.