我有以下两个数组:
$Array1 = array(array('x1','x2','x3'),array('x4','x5','x6'));
$Array2 = array(array('z1','z2','z3'),array('z4','z5','z6'));
打印时它们返回:
Array
(
[0] => Array
(
[x1] => x1
[x2] => x2
[x3] => x3
)
[1] => Array
(
[x4] => x4
[x5] => x5
[x6] => x6
)
)
Array
(
[0] => Array
(
[z1] => z1
[z2] => z2
[z3] => z3
)
[1] => Array
(
[z4] => z4
[z5] => z5
[z6] => z6
)
)
我如何将它们组合成一个数组,如下例所示,它们使用相同的键组合:
Array
(
[0] => Array
(
[x1] => x1
[x2] => x2
[x3] => x3
[z1] => z1
[z2] => z2
[z3] => z3
)
[1] => Array
(
[x4] => x4
[x5] => x5
[x6] => x6
[z1] => z4
[z2] => z5
[z3] => z6
)
)
我试过使用:
array_merge=($Array1,$Array2)
array_merge_recursive($Array1,$Array2)
array_combine($Array1,$Array2) [which genereated an error, so I guess I was using it wrong]
$Array1 + $Array2
但这些都没有奏效。