note 67686 added to language.types.array
| From: | ch dot martin at gmail dot com | Date: | Fri, 09 Jun 2006 06:40:12 +0000 |
| Subject: | note 67686 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114034@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 64.71.164.2
Probable Submitter: 70.34.157.184
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/note/edit/67686
Del: integrated -- http://master.php.net/note/delete/67686/integrated
Del: useless -- http://master.php.net/note/delete/67686/useless
Del: bad code -- http://master.php.net/note/delete/67686/bad+code
Del: spam -- http://master.php.net/note/delete/67686/spam
Del: non-english -- http://master.php.net/note/delete/67686/non-english
Del: in docs -- http://master.php.net/note/delete/67686/in+docs
Del: other reasons-- http://master.php.net/note/delete/67686
Reject -- http://master.php.net/note/reject/67686
Search -- http://master.php.net/manage/user-notes.php