php-将一列上的数组数据分组,并对另一列中的数据求和
发布时间:2022-05-21 17:48:58 252
相关标签: # 后端
我的数组数据如下所示:
$array = [
['name' => 'Bank BRI', 'amount' => 0],
['name' => 'Bank BRI', 'amount' => 0],
['name' => 'Bank BCA', 'amount' => 1412341234],
['name' => 'Bank CIMB Niaga', 'amount' => 532532552],
['name' => 'Bank BRI', 'amount' => 34534534],
['name' => 'Bank CIMB Niaga', 'amount' => 453425243],
['name' => 'Bank BRI', 'amount' => 0],
['name' => 'Bank BNI', 'amount' => 124124],
['name' => 'Bank CIMB Niaga', 'amount' => 352345623],
['name' => 'Bank BCA', 'amount' => 23432423],
['name' => 'Bank Mandiri', 'amount' => 0],
['name' => 'Bank BCA', 'amount' => 0],
['name' => 'Bank BCA', 'amount' => 0],
['name' => 'Bank Permata', 'amount' => 352352353],
];
如何根据相同的“银行名称”合计“金额”。
我的结果应显示分组名称及其合计金额:
array (
'Bank BRI' => 34534534,
'Bank BCA' => 1435773657,
'Bank CIMB Niaga' => 1338303418,
'Bank BNI' => 124124,
'Bank Mandiri' => 0,
'Bank Permata' => 352352353,
)
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报