How can I add all the columnar values by associative key? Note that key sets are dynamic.
Input array:
Arr
Code here:
$temp_arr = []; foreach ($a as $k => $v) { if(!is_null($v)) { $sum = isset($temp_arr[$v[0]]) ? ((int)$v[5] + $sum) : (int)$v[5]; $temp_arr[$v[0]] = $sum; } } return $temp_arr;
Result:
{SEQ_OK: 1328,SEQ_ERROR: 561}