I have an array of objects, and i want to sum value of one of the properties, example:
Array
(
[0] => stdClass Object
(
[name] => jon
[commission] => 5
)
[1] => stdClass Object
(
[name] => smith
[commission] => 1
)
[2] => stdClass Object
(
[name] => philip
[commission] => 8
)
)
I want to sum all the commissions in the array, result should be 14.
What is a good way for this?
See Question&Answers more detail:os