note 92186 added to language.types.array
| From: | Ant-1 at osu1 dot php dot net | Date: | Mon, 13 Jul 2009 16:12:41 +0000 |
| Subject: | note 92186 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158234@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 66.207.199.35
Probable Submitter: 208.84.104.226
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/92186
Del: integrated -- https://master.php.net/note/delete/92186/integrated
Del: useless -- https://master.php.net/note/delete/92186/useless
Del: bad code -- https://master.php.net/note/delete/92186/bad+code
Del: spam -- https://master.php.net/note/delete/92186/spam
Del: non-english -- https://master.php.net/note/delete/92186/non-english
Del: in docs -- https://master.php.net/note/delete/92186/in+docs
Del: other reasons-- https://master.php.net/note/delete/92186
Reject -- https://master.php.net/note/reject/92186
Search -- https://master.php.net/manage/user-notes.php