3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array1 = array(2,10,4,5,2,1); $array2 = array('A','B','C','D','E','F'); $array3 = array_combine($array2, $array1); arsort($array3); $skip = 0; $i = 0; $temp = null; foreach($array3 as $k => $v) { if($temp !== $v) {$i++; $i += $skip; $skip = 0;}else {$skip++;} $temp = $v; echo $k, ' Rank: ', $i, "\n"; }
Output for 5.6.0 - 7.3.0rc4
B Rank: 1 D Rank: 2 C Rank: 3 A Rank: 4 E Rank: 4 F Rank: 6