3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = Array ( "0" => 12 , "1" => 12 , "2" => 5, "3" => 27, "4" => 5 ); $i=1; foreach($array as $key=>$values) { $max = max($array); echo "\n".$max." rank is ". $i."\n"; $keys = array_search($max, $array); unset($array[$keys]); if(sizeof($array) >0) if(!in_array($max,$array)) $i++; }
based on S8Den
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.22.0, 7.0.0 - 7.3.0beta1
27 rank is 1 12 rank is 2 12 rank is 2 5 rank is 3 5 rank is 3