3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $grades = array(92, 84, 84, 84, 83, 65, 41, 38, 37, 37); $occurrences = array_count_values($grades); $grades = array_unique($grades); foreach($grades as $grade) { if($grade == end($grades))$i += $occurrences[$grade]-1; echo str_repeat($grade .' - '.($i+1).'<br>',$occurrences[$grade]); $i += $occurrences[$grade]; }
based on Hgj5P
Output for 5.0.4 - 7.2.0
Notice: Undefined variable: i in /in/M0Qo9 on line 7 92 - 1<br> Notice: Undefined variable: i in /in/M0Qo9 on line 8 84 - 2<br>84 - 2<br>84 - 2<br>83 - 5<br>65 - 6<br>41 - 7<br>38 - 8<br>37 - 10<br>37 - 10<br>
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: i in /in/M0Qo9 on line 7 92 - 1<br> Notice: Undefined variable: i in /in/M0Qo9 on line 8 84 - 2<br>84 - 2<br>84 - 2<br>83 - 5<br>65 - 6<br>41 - 7<br>38 - 8<br>37 - 10<br>37 - 10<br>