note 95795 added to function.array-merge
| From: | riddlemd at gmail dot com | Date: | Fri, 22 Jan 2010 08:43:14 +0000 |
| Subject: | note 95795 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165195@lists.php.net to get a copy of this message | ||
Apparently there is a shorthand that works very much like array_merge. I figured I would leave a
comment here, sense I saw it used in code but found nothing about it from google searches.
<?php
$array = array(
'name' => 'John Doe'
);
$array += array(
'address' => 'someplace somestreet'
);
echo $array['address']; // Outputs 'someplace somestreet'
?>
A difference from merge_array, it does NOT overwrite existing keys, regardless of key type.
----
Server IP: 69.147.83.197
Probable Submitter: 70.185.231.200
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/95795
Del: integrated -- https://master.php.net/note/delete/95795/integrated
Del: useless -- https://master.php.net/note/delete/95795/useless
Del: bad code -- https://master.php.net/note/delete/95795/bad+code
Del: spam -- https://master.php.net/note/delete/95795/spam
Del: non-english -- https://master.php.net/note/delete/95795/non-english
Del: in docs -- https://master.php.net/note/delete/95795/in+docs
Del: other reasons-- https://master.php.net/note/delete/95795
Reject -- https://master.php.net/note/reject/95795
Search -- https://master.php.net/manage/user-notes.php