note 1062 deleted from Arrays by jeroen
| From: | jeroen@php.net | Date: | Wed, 23 May 2001 23:24:23 +0000 |
| Subject: | note 1062 deleted from Arrays by jeroen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14223@lists.php.net to get a copy of this message | ||
Array indices will be promoted to being integers if possible, even if you try to force the type.
For example:
<PRE>
$myArray["100"] = "test";
print($myArray[100]);
</PRE>
will print
<PRE>
test
</PRE>
Strings that look like integers, but have leading zeroes will not be promoted, however as in
<PRE>
$myArray["001"] = "test";
print($myArray[1]);
</PRE>
which prints nothing.
While this might seem limiting, it's really a protection against confusing cases where a
variable's type is string, but you want to use it reference an array element that was set with
an integer. It elminates a lot of wasteful castes.