array_merge是丟棄原來的數字的key,而保留字串形式的key,然後組成一個新的數組,不管鍵名
是否一樣,都不合併,除非鍵名和value同時一樣並且還必須是字符串形式的key才合併。而array+array就
是不管你是什麼情況,它都只會先把前面的數組的資料先放到新生成的數組中,之後再看第二個array是否
比第一個數組個數多,多的就加進來,它只數個數,但是這種情況它會加進來:
$a = array('d'=>'aass','e'=>'adsdfd', 'asd'=>'asdsdd','ddfg'=>'dssdf');
$b = array('d'=>'adddd','adsdfd','asdfsddddd','d'=>'aass' );
$d = $a + $b;
$e = array_merge($a,$b);
var_dump($d);
var_dump($e);列印: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)