1 回答
TA贡献2003条经验 获得超2个赞
关于什么:
$finalArray = array();
foreach ($array1 as $arr1)
{
$amount = 0;
foreach ($array2 as $key2 => $arr2)
{
if ($arr1['ID'] === $arr2['ID'])
{
$amount += $arr2['Amount'];
unset($array2[$key2]);
}
}
$finalArray[] = array_merge($arr1, array(
'Amount' => $amount,
'Found' => $amount ? "Yes" : "No"
));
}
print_r($finalArray);
输出:
Array
(
[0] => Array
(
[ID] => 101
[Code] => 1075
[Date] => 2012-03-03 17:13:12.433
[amount] => 6890
[found] => Yes
)
[1] => Array
(
[ID] => 103
[Code] => 175
[Date] => 2012-09-05 20:30:02.217
[amount] => 1342
[found] => Yes
)
[2] => Array
(
[ID] => 109
[Code] => 178
[Date] => 2012-07-05 20:30:02.217
[amount] => 0
[found] => No
)
)
如果您需要任何进一步的解释,请告诉我。
- 1 回答
- 0 关注
- 155 浏览
添加回答
举报