multidimensional array array_sum
I would use array_map to reduce the array to only what is needed. Bear in mind, this will only work with PHP 5.3 onwards.
$total_vat = array_sum( array_map(
function($element){
return $element['vatAmount'];
},
$account_invoices));
Just a way to do it:
$sum = 0;
foreach($account_invoices as $num => $values) {
$sum += $values[ 'vatAmount' ];
}
If you have PHP 5.5+ you can do this without looping or using a callback (since function calls are relatively expensive) ... just use:
$sum = array_sum(array_column($account_invoices, 'vatAmount'));