Array_merge discards the original numeric key, retains the key in string form, and then forms a new array. Regardless of whether the key names are the same, they will not be merged unless the key name and value are the same at the same time and must be a string key. merge. And array+array means that no matter what your situation is, it will only put the data of the previous array into the newly generated array first, and then check whether the second array has more elements than the first array. If there are more Just add it in, it only counts the number, but in this case it will be added in: $a = array('d'=>'aass','e'=>'adsdfd','asd' =>'asdsdd','ddfg'=>'dssdf');
Copy code The code is as follows:
$b = array('d'=>'adddd','adsdfd','asdfsddddd','d'=>'aass');
$d = $a + $b;
$e = array_merge($a,$b);
var_dump($d);
var_dump($e);
Print:
array
'd' => string 'aass' (length=4)
'e' => string 'adsdfd' (length=6)
'asd ' => string 'asdsdd' (length=6)
'ddfg' => string 'dssdf' (length=5)
0 => string 'adsdfd' (length=6)
1 => string 'asdfsddddd' (length=10)
array
'd' => string 'aass' (length=4)
'e' => string 'adsdfd' (length=6)
'asd' => string 'asdsdd' (length=6)
'ddfg' => string 'dssdf' (length=5 )
0 => string 'adsdfd' (length=6)
1 => string 'asdfsddddd' (length=10)
http://www.bkjia.com/PHPjc/327779.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327779.htmlTechArticlearray_merge discards the original numeric key, retains the key in string form, and then forms a new array, Regardless of whether the key names are the same, they will not be merged unless the key name and value are the same at the same time...