I'm trying to convert an array, to one where specific values are summed up 'distincted' on another value.
Let me be specific:
Array
(
[0] => stdClass Object
(
[id_space] => LIVING
[running_meters] => 4.22
)
[1] => stdClass Object
(
[id_space] => LIVING
[running_meters] => 9.69
)
[2] => stdClass Object
(
[id_space] => LIVING
[running_meters] => 32.79
)
[3] => stdClass Object
(
[id_space] => KITCHEN
[running_meters] => 30.34
)
[4] => stdClass Object
(
[id_space] => KITCHEN
[running_meters] => 22.83
)
[5] => stdClass Object
(
[id_space] => KITCHEN
[running_meters] => 24.00
)
[6] => stdClass Object
(
[id_space] => HALL
[running_meters] => 5.83
)
[7] => stdClass Object
(
[id_space] => HALL
[running_meters] => 21.81
)
)
Converted to:
Array
(
[0] => stdClass Object
(
[id_space] => LIVING
[running_meters] => 46.7
)
[1] => stdClass Object
(
[id_space] => KITCHEN
[running_meters] => 53,17
)
[2] => stdClass Object
(
[id_space] => HALL
[running_meters] => 24.00
)
)
So I get the sum of the running_meters of each 'space'.
Thanks in advance, appreciate it.
I think searched all related questions here on the onlines, but all of them counted number of items in an array, not the sum of the values.