Php associative array sort and get key with highest length

Viewed 2115

Hey i have an associative array which has keys as String and values as Int. So from that associative array i need to get the key which has the highest value and if multiple keys have the same value then i need the key with the highest length.

So whats the most efficient way of doing this?

example

array = (
    'abc'     => 10,
    'def'     => 8,
    'fff'     => 3,
    'abcr'    => 10,
    'adsfefs' => 10
)

So for this i should get output as adsfefs

3 Answers
Related