foreach ($arr as $ind=>$usersBlock) {
$keys = [];
foreach ($usersBlock as $user) {
$key = $user['user_id'] . '#' . $user['date'];
list($hours, $minutes, $seconds) = explode(':', $user['time']);
$seconds += $minutes * 60 + $hours * 3600;
if(!isset($keys[$key])) {
$keys[$key] = $user;
$keys[$key]['seconds'] = $seconds;
} else {
$keys[$key]['seconds'] += $seconds;
}
}
$arr[$ind] = [];
foreach ($keys as $key => $value) {
$value['time'] = convertToTime($value['seconds']);
unset($value['seconds']);
$arr[$ind][] = $value;
}
}
function convertToTime($seconds) {
// Напишите конвертацию секунд в полноценное время сами
return $seconds;
}