Reputation: 3
How can I get max key from same value?
Example:
1 => 32
2 => 32
3 => 32
4 => 5
5 => 5
6 => 11
7 => 11
Result:
3 => 32
5 => 5
7 => 11
Upvotes: 0
Views: 67
Reputation: 212412
Assuming values are all integer
$array = [
1 => 32,
2 => 32,
3 => 32,
4 => 5,
5 => 5,
6 => 11,
7 => 11,
];
$result = array_flip(array_flip($array));
var_dump($result);
Upvotes: 2