我正在为Magento soap调用格式化数组。我有两个mysql查询,ARRAY1和ARRAY2是结果。我如何合并/组合ARRAY1和ARRAY2,以便结果像ARRAY3?
我感谢任何帮助。
ARRAY1
<pre>
array(2) {
[0]=>
array(3) {
[0]=>
string(6) "store1"
[1]=>
string(8) "product1"
}
[1]=>
array(3) {
[0]=>
string(6) "store1"
[1]=>
string(8) "product2"
}
[2]=>
array(2) {
[0]=>
string(6) "store2"
[1]=>
string(8) "product2"
}
}
</pre>
ARRAY2
<pre>
array(3) {
[0]=>
array(1) {
["status"]=>
string(3) "Yes"
}
[1]=>
array(1) {
["status"]=>
string(2) "No"
}
[2]=>
array(1) {
["status"]=>
string(3) "Yes"
}
}
</pre>
ARRAY3
<pre>
array (size=3)
0 =>
array (size=3)
0 => string 'store1' (length=6)
1 => string 'product1' (length=8)
2 =>
array (size=1)
'status' => string 'Yes' (length=3)
1 =>
array (size=3)
0 => string 'store1' (length=6)
1 => string 'product2' (length=8)
2 =>
array (size=1)
'status' => string 'No' (length=2)
2 =>
array (size=3)
0 => string 'store2' (length=6)
1 => string 'product2' (length=8)
2 =>
array (size=1)
'status' => string 'No' (length=2)
</pre>
答案 0 :(得分:0)
假设两个阵列完美排列,这可能会有所帮助:
<?php
$i = 0;
foreach ($array1 as $item) {
array_push($item, $array2[$i]);
$i++;
}
?>