方法一
$a = array(
'a'=>'a1',
'b'=>'b1',
'c1',
);
$b = array(
'a'=>'a2',
'e'=>'b2',
'c2',
);
$a = array_values($a);
$b = array_values($b);
var_dump(array_merge($a,$b));
效果
array(6) {
[0]=>
string(2) "a1"
[1]=>
string(2) "b1"
[2]=>
string(2) "c1"
[3]=>
string(2) "a2"
[4]=>
string(2) "b2"
[5]=>
string(2) "c2"
}
0.000102996826172
方法二
$a = array(
'a'=>'a1',
'b'=>'b1',
'c1',
);
$b = array(
'a'=>'a2',
'e'=>'b2',
'c2',
);
$a = array_values($a);
foreach ($b as $val){
array_push($a,$val);
}
var_dump($a);
效果:
array(6) {
[0]=>
string(2) "a1"
[1]=>
string(2) "b1"
[2]=>
string(2) "c1"
[3]=>
string(2) "a2"
[4]=>
string(2) "b2"
[5]=>
string(2) "c2"
}
0.000110149383545