$vals = array(51, 23, 77, 3, 8, 31, 17, 102, 87);
arsort($vals);
From here, how can I get the keys of the 3 first values? If I do $vals[0] it won’t work because it’ll return me the original [0] key before the arsort.
I want to get the original keys of 102, 87 and 77 after arsort.
Depending on what you need it for, one way is
$keys[0] will contain the first key.
$vals[$keys[0]] will contain the first value.
An alternate way
$part will contain three $key => $value pairs for the first three entries.
And for the first three keys, you can mix and match the above, such as: