note 13888 deleted from language.types.array.php by jeroen
| From: | jeroen@php.net | Date: | Sun, 08 Jul 2001 20:03:57 +0000 |
| Subject: | note 13888 deleted from language.types.array.php by jeroen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15099@lists.php.net to get a copy of this message | ||
If using associative arrays with strings as keys, I would recommend explicitly quoting the keys,
i.e. use $array["$key"] instead of $array [$key]. You might run into trouble with PHP not
finding your array elements if $key is numeric but meant to be an associative key because PHP would
interpret $array [$key] as an access to an indexed array. By quoting you kind of type cast the key
to a string.
I'll give an example to clarify:
Define
$a ["abc"] = "one";
$a ["234"] = "two";
Now try:
print $a ["abc"] works as expected
print $a ["234"] works as expected
but print $a [234] will *not*
Maybe this should be added to the manual somewhere.
Steve