note 85451 added to function.array-merge
| From: | carrox at inbox dot lv | Date: | Sun, 31 Aug 2008 23:41:21 +0000 |
| Subject: | note 85451 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144034@lists.php.net to get a copy of this message | ||
Usage of operand '+' for merging arrays:
<?php
$a=array(
'a'=>'a1',
'b'=>'a2',
'a3',
'a4',
'a5');
$b=array('b1',
'b2',
'a'=>'b3',
'b4');
$a+=$b;
print_r($a);
?>
output:
Array
(
[a] => a1
[b] => a2
[0] => a3
[1] => a4
[2] => a5
[3] => b5
)
numeric keys of elements of array B what not presented in array A was added.
<?php
$a=array('a'=>'a1','b'=>'a2','a3','a4','a5');
$b=array(100=>'b1','b2','a'=>'b3','b4');
$a+=$b;
print_r($a);
?>
output:
[a] => a1
[b] => a2
[0] => a3
[1] => a4
[2] => a5
[100] => b1
[101] => b2
[102] => b4
autoindex for array B started from 100, these keys not present in array A, so this elements was
added to array A
----
Server IP: 195.54.192.44
Probable Submitter: 127.0.0.1
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/85451
Del: integrated -- https://master.php.net/note/delete/85451/integrated
Del: useless -- https://master.php.net/note/delete/85451/useless
Del: bad code -- https://master.php.net/note/delete/85451/bad+code
Del: spam -- https://master.php.net/note/delete/85451/spam
Del: non-english -- https://master.php.net/note/delete/85451/non-english
Del: in docs -- https://master.php.net/note/delete/85451/in+docs
Del: other reasons-- https://master.php.net/note/delete/85451
Reject -- https://master.php.net/note/reject/85451
Search -- https://master.php.net/manage/user-notes.php