我有一个这样的PHP数组:
Array ( [0] => Array ( [url_id] => 2191238 [time_spent] => 41 ) [1] => Array ( [url_id] => 2191606 [time_spent] => 215 ) [2] => Array ( [url_id] => 2191606 [time_spent] => 25 ) )
因此,如何time_spent通过url_id 获取基于组的SUM(使用array_count_values)
time_spent
为什么不更简单
$ts_by_url = array(); foreach($array as $data) { $ts_by_url[ $data['url_id'] ] += $data['time_spent']; }