note 85451 deleted from function.array-merge by salathe

From: Date: Mon, 06 Sep 2021 22:45:05 +0000
Subject: note 85451 deleted from function.array-merge by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-216893@lists.php.net to get a copy of this message
Note Submitter: carrox at inbox dot lv ---- 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

« previous php.notes (#216893) next »