Hello, I would like to find arrays with same value of key **EAN** . If multiple records exist, I want to remove the record with lower value of key **ProductCount** .

For example I have an array. As you can see there are three records with the **same ean** ($arr[0], $arr[1], $a[3]). After finding these records with the same ean I need to compare their values of key ProductCount and keep the record with the **smallest value** of ProductCount. Do you understand?

I would be thankful for any advice.

```
$arr =array(
"0" => Array
(
"ean" => 6900532615069,
"productPrice" => 1140,
"productCount" => 5
),
"1" => Array
(
"ean" => 6900532615069,
"productPrice" => 1140,
"productCount" => 50
),
"2" => Array
(
"ean" => 6900535364122,
"productPrice" => 1140,
"productCount" => 50
),
"3" => Array
(
"ean" => 6900532615069,
"productPrice" => 1140,
"productCount" => 10,
));
```

So output should be

```
$arr =array(
"0" => Array
(
"ean" => 6900532615069,
"productPrice" => 1140,
"productCount" => 5
),
"1" => Array
(
"ean" => 6900535364122,
"productPrice" => 1140,
"productCount" => 50
));
```

I try this and some modifications of this but without any success.

```
function removeduplicateKeys($data){
$_data = array();
foreach ($data as $v) {
if (isset($_data[$v['ean']])) {
// found duplicate
continue;
}
// remember unique item
$_data[$v['ean']] = $v;
}
$data = array_values($_data);
return $data;
}
```

Thank you