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'));
More Related Contents:
- PHP Array_Sum on multi dimensional array
- How to search by key=>value in a multidimensional array in PHP
- In PHP, how do you change the key of an array element?
- php $_POST array empty upon form submission
- How to generate in PHP all combinations of items in multiple arrays
- What is the best way to loop through this array in PHP?
- Find a matching or closest value in an array
- What’s the best way to get the last element of an array without deleting it?
- PHP: Access Array Value on the Fly
- Search for a key in an array, recursively
- Get the first N elements of an array?
- php var_dump() vs print_r()
- Posting array from form
- How to get common values from two different arrays in PHP [closed]
- Comment associative array in PHP Documentor
- What is the meaning of [] [closed]
- Unsetting array values in a foreach loop [duplicate]
- PHP – Find parent key of array
- Warning: array_combine(): Both parameters should have an equal number of elements
- Returning first x items from array
- Prepend associative array elements to an associative array
- What is the difference between array_udiff_assoc() and array_diff_uassoc()?
- How do I declare a two dimensional array?
- How to force Doctrine to update array type fields?
- Combine two 2d arrays and have duplicate rows removed
- How to create multi-dimensional array from a list?
- Alternate to array_column()
- How to convert an integer to an array in PHP?
- Save array in mysql database
- How do I check if array contains at least one empty value?