I do not think that there is a built-in function that will allow you to summarize the values ββof a multidimensional array. However, here you can do this using the lambda-style function.
Suppose this is your array:
[items] => Array ( [0] => Array ( [ID] => 11 [barcode] => 234334 [manufacturer] => Dell [model] => D630 [serial] => 324233 [current_value] => 1100.00 ) [1] => Array ( [ID] => 22 [barcode] => 323552 [manufacturer] => Dell [model] => D630 [serial] => 234322 [current_value] => 1500.00 ) )
You can create a function that you could pass values ββto:
$array_value_sum = create_function('$array,$key', '$total = 0; foreach($array as $row) $total = $total + $row[$key]; return $total;');
And then use it like this:
echo "Total Current Value" . $array_value_sum($obj['items'], 'current_value');
source share