我有如下所示的数组。我想要一个结果数组,其中键元素[tv]
, [tu]
,[cost]
中[km]
的值对所有具有相同值的行求和[tick_id]
。在这个例子中,我们应该对数组元素 0, 1, 2, ... 的值[tv]
, [tu]
, [cost]
,求和[km]
,我该怎么做呢?
Array (
[0] => stdClass Object (
[id] => 15
[user_id] => 44
[name] => inspector1
[tv] => 0.00
[tc] => 0.00
[tu] => 0.00
[cost] => 0.00
[kms] => 0
[date_s] => 2012-03-30
[notes] =>
[tick_id] => 11
[tot_fee] => 5500
)
[1] => stdClass Object (
[id] => 39
[user_id] => 46
[name] => Assistant
[tv] => 10.00
[tc] => 0.00
[tu] => 4.50
[cost] => 0.00
[kms] => 120
[date_s] => 2012-03-31
[notes] =>
[tick_id] => 15
[tot_fee] => 0
)
[2] => stdClass Object (
[id] => 35
[user_id] => 46
[name] =>
[tv] => 0.00
[tc] => 0.00
[tu] => 0.00
[cost] => 0.00
[kms] => 0
[date_s] => 2012-03-30
[notes] =>
[tick_id] => 13
[tot_fee] => 3200
)
…
)