3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = Array ( "0" => 12 , "1" => 17 , "2" => 5, "3" => 27, "4" => 5 ); sort($array); print_r($array); $arrayValues = $array; $ranked = sort($arrayValues); for($i = 0; $i < sizeof($ranked); $i++){ for($j = 0; $j < sizeof($arrayValues); $j++){ if($arrayValues[$i] == $sorted[$j]){ echo $arrayValues[$i] . ' has rank ' . $j; } } }
Output for 7.2.0 - 7.2.6
Array ( [0] => 5 [1] => 5 [2] => 12 [3] => 17 [4] => 27 ) Warning: sizeof(): Parameter must be an array or an object that implements Countable in /in/hMoRP on line 12 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Warning: sizeof(): Parameter must be an array or an object that implements Countable in /in/hMoRP on line 12
Output for 5.0.4 - 7.1.20
Array ( [0] => 5 [1] => 5 [2] => 12 [3] => 17 [4] => 27 ) Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14
Output for 4.3.0 - 5.0.3
Array ( [0] => 5 [1] => 5 [2] => 12 [3] => 17 [4] => 27 ) Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14 Notice: Undefined variable: sorted in /in/hMoRP on line 14