3v4l.org

run code in 300+ PHP versions simultaneously
<?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]; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 32
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 32
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/M0Qo9
function name:  (null)
number of ops:  34
compiled vars:  !0 = $grades, !1 = $occurrences, !2 = $grade, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        INIT_FCALL                                               'array_count_values'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !1, $5
    4     5        INIT_FCALL                                               'array_unique'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !0, $7
    5     9      > FE_RESET_R                                       $9      !0, ->32
         10    > > FE_FETCH_R                                               $9, !2, ->32
    6    11    >   INIT_FCALL                                               'end'
         12        SEND_REF                                                 !0
         13        DO_ICALL                                         $10     
         14        IS_EQUAL                                                 !2, $10
         15      > JMPZ                                                     ~11, ->19
         16    >   FETCH_DIM_R                                      ~12     !1, !2
         17        SUB                                              ~13     ~12, 1
         18        ASSIGN_OP                                     1          !3, ~13
    7    19    >   INIT_FCALL                                               'str_repeat'
         20        CONCAT                                           ~15     !2, '+-+'
         21        ADD                                              ~16     !3, 1
         22        CONCAT                                           ~17     ~15, ~16
         23        CONCAT                                           ~18     ~17, '%3Cbr%3E'
         24        SEND_VAL                                                 ~18
         25        FETCH_DIM_R                                      ~19     !1, !2
         26        SEND_VAL                                                 ~19
         27        DO_ICALL                                         $20     
         28        ECHO                                                     $20
    8    29        FETCH_DIM_R                                      ~21     !1, !2
         30        ASSIGN_OP                                     1          !3, ~21
    5    31      > JMP                                                      ->10
         32    >   FE_FREE                                                  $9
    9    33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.86 ms | 1400 KiB | 21 Q