我有$array1
,$array2
它们都是CodeIgniter的结果 ->result_array()
阵列 1
Array(
[0] => Array(
[name] => John,
[course] => BSIT
),
[1] => Array(
[name] => Jane,
[course] => BSHRM
)
)
阵列2
Array(
[0] => Array(
[balance] => 1000,
[date] => 2013-05-01
),
[1] => Array(
[balance] => 2000,
[date] => 2013-05-07
)
)
我的问题是我怎样才能将元素附加到[balance], [date]
它看起来像这样的东西:$array2
$array1
Array(
[0] => Array(
[name] => John,
[course] => BSIT
[balance] => 1000,
[date] => 2013-05-01
),
[1] => Array(
[name] => Jane,
[course] => BSHRM
[balance] => 2000,
[date] => 2013-05-07
)
)
我试过了:
for($i = 0; $i<count($array1); $i++)
{
array_merge($array1[$i], $array2[$i]);
}
但它似乎不起作用:arguments are not array
即使我这样做,我也会收到一个错误:
for($i = 0; $i<count($array1); $i++)
{
array_merge(array($array1[$i]), array($array2[$i]));
}
这怎么可能?