note 30132 deleted from language.types.array by googleguy
| From: | googleguy@php.net | Date: | Sat, 12 Jan 2013 15:42:14 +0000 |
| Subject: | note 30132 deleted from language.types.array by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192997@lists.php.net to get a copy of this message | ||
Note Submitter:
----
"Using NULL as a key will evaluate to an empty string. Using an emptry string as key will
create (or overwrite) a key with an empty string and its value, it is not the same as using empty
brackets."
If you create an array like this:
<?php $foo = array(null => 'bar'); ?>
And then want to access 'bar', you must use this syntax:
<?php echo $foo['']; // notice the two single quotes ?>
This will of course cause a fatal error:
<?php echo $foo[]; ?>