$arr = [['name' => 'ford', 'count' => 2], ['name' => 'ford', 'count' => 8], ['name' => 'lada', 'count' => 9], ['name' => 'lada', 'count' => 2]]
$arr = [['name' => 'ford', 'count' => 2],
['name' => 'ford', 'count' => 8],
['name' => 'lada', 'count' => 9],
['name' => 'lada', 'count' => 2]];
$result = [];
foreach($arr as $car) {
if (!isset($result[$car['name']]) || $result[$car['name']] < $car['count']) {
$result[$car['name']] = $car['count'];
}
}
<?php
$arr = [
['name' => 'ford', 'count' => 2],
['name' => 'ford', 'count' => 8],
['name' => 'lada', 'count' => 9],
['name' => 'lada', 'count' => 2]
];
$res = array_reduce($arr, function($carry, $item) {
if(!isset($carry[$item['name']]) || ($carry[$item['name']] < $item['count']) ) {
$carry[$item['name']] = $item['count'];
}
return $carry;
});
var_dump($res);