note 96844 added to function.array-merge
| From: | nekroshorume at gmail dot com | Date: | Thu, 18 Mar 2010 18:31:40 +0000 |
| Subject: | note 96844 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167177@lists.php.net to get a copy of this message | ||
be aware there is a slight difference:
$array1 = array('lang'=>'js','method'=>'GET');
$array2 =
array('lang'=>'php','browser'=>'opera','method'=>'POST');
BETWEEN:
array_merge($array2,$array1);
outputs: Array ( [lang] => js [browser] => opera [method] => GET )
notice that the repeated keys will be overwritten by the ones of $array1, maintaining those, because
it is the array that is being merged
AND
array_merge($array1,$array2);
outputs: Array ( [lang] => php [method] => POST [browser] => opera )
here the oposite takes place: array1 will have its elements replaced by those of array2.
----
Server IP: 69.147.83.197
Probable Submitter: 189.30.229.203
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/96844
Del: integrated -- https://master.php.net/note/delete/96844/integrated
Del: useless -- https://master.php.net/note/delete/96844/useless
Del: bad code -- https://master.php.net/note/delete/96844/bad+code
Del: spam -- https://master.php.net/note/delete/96844/spam
Del: non-english -- https://master.php.net/note/delete/96844/non-english
Del: in docs -- https://master.php.net/note/delete/96844/in+docs
Del: other reasons-- https://master.php.net/note/delete/96844
Reject -- https://master.php.net/note/reject/96844
Search -- https://master.php.net/manage/user-notes.php