I have my array data as shown below:
$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],
];
How to sum 'amount' based on same 'bank name'.
My result should show grouped names and their summed amount:
array (
'Bank BRI' => 34534534,
'Bank BCA' => 1435773657,
'Bank CIMB Niaga' => 1338303418,
'Bank BNI' => 124124,
'Bank Mandiri' => 0,
'Bank Permata' => 352352353,
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…