<?php
$array = [
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
[
'player_id' => 1,
'count_goals' => 1
],
];
function filter($array)
{
$result = [];
foreach($array as $key => $value) {
if (array_key_exists($value['player_id'], $result)) {
$result[$value['player_id']]['count_goals'] += $value['count_goals'];
} else {
$result[$value['player_id']] = $value;
}
}
return array_values($result);
}
print_r(filter($array));