3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = Array ( "0" => 12 , "1" => 17 , "2" => 5, "3" => 27, "4" => 5 ); $arrays = $array; //print_r($array); $i=1; foreach($arrays as $key=>$values) { echo "\n".max($array)." rank is ". $i."\n";print_r($array); $keys = array_search(max($array), $array); unset($array[$keys]); if(!in_array(max($array),$array)) $i++; }
Output for 5.2.5 - 7.1.0
27 rank is 1 Array ( [0] => 12 [1] => 17 [2] => 5 [3] => 27 [4] => 5 ) 17 rank is 1 Array ( [0] => 12 [1] => 17 [2] => 5 [4] => 5 ) 12 rank is 1 Array ( [0] => 12 [2] => 5 [4] => 5 ) 5 rank is 1 Array ( [2] => 5 [4] => 5 ) 5 rank is 1 Array ( [4] => 5 ) Warning: max(): Array must contain at least one element in /in/fP10v on line 13
Output for 4.3.2 - 5.2.4
27 rank is 1 Array ( [0] => 12 [1] => 17 [2] => 5 [3] => 27 [4] => 5 ) 17 rank is 1 Array ( [0] => 12 [1] => 17 [2] => 5 [4] => 5 ) 12 rank is 1 Array ( [0] => 12 [2] => 5 [4] => 5 ) 5 rank is 1 Array ( [2] => 5 [4] => 5 ) 5 rank is 1 Array ( [4] => 5 ) Warning: max(): Array must contain atleast one element in /in/fP10v on line 13
Output for 4.3.0 - 4.3.1
27 rank is 1 Array ( [0] => 12 [1] => 17 [2] => 5 [3] => 27 [4] => 5 ) 17 rank is 1 Array ( [0] => 12 [1] => 17 [2] => 5 [4] => 5 ) 12 rank is 1 Array ( [0] => 12 [2] => 5 [4] => 5 ) 5 rank is 1 Array ( [2] => 5 [4] => 5 ) 5 rank is 1 Array ( [4] => 5 ) Warning: max() [http://www.php.net/function.max]: Array must contain atleast one element in /in/fP10v on line 13