note 92186 deleted from language.types.array by danbrown
| From: | danbrown@php.net | Date: | Wed, 05 Oct 2011 22:47:45 +0000 |
| Subject: | note 92186 deleted from language.types.array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183652@lists.php.net to get a copy of this message | ||
Note Submitter: Ant-1
----
Note for PHP 5.3 changed behavior in 'erroneous' array creation:
Prior to PHP 5.3, this array definition (note the duplicate key):
<?php $a = array ('foo' => 1, 'bar' => 2, 'foo' => 3);
?>
Would create the following array:
array(
'foo' => 3,
'bar' => 2
)
So the /second/ key in the duplicate would override the first declaration.
Now with PHP 5.3, the following array will be created:
array(
'foo' => 1,
'bar' => 2
)
So the second duplicate key would be ignored.
Note that the array declaration indeed contains an error, but if your legacy code contains such
array declaration, you will be hurt because of the changed behavior.