3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['A', 'A', 'B', 'B', 'C', 'A', 'A']; $result = []; foreach ($array as $v) { if (!isset($ref[$v])) { unset($ref); $ref[$v] = 1; $result[$v][] =& $ref[$v]; } else { ++$ref[$v]; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/DN7vO
function name:  (null)
number of ops:  24
compiled vars:  !0 = $array, !1 = $result, !2 = $v, !3 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $6      !0, ->19
          3    > > FE_FETCH_R                                               $6, !2, ->19
    7     4    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !3, !2
          5        BOOL_NOT                                         ~8      ~7
          6      > JMPZ                                                     ~8, ->16
    8     7    >   UNSET_CV                                                 !3
    9     8        ASSIGN_DIM                                               !3, !2
          9        OP_DATA                                                  1
   10    10        FETCH_DIM_W                                      $12     !3, !2
         11        MAKE_REF                                         $13     $12
         12        FETCH_DIM_W                                      $10     !1, !2
         13        FETCH_DIM_W                                      $11     $10
         14        ASSIGN_REF                                               $11, $13
    7    15      > JMP                                                      ->18
   12    16    >   FETCH_DIM_RW                                     $15     !3, !2
         17        PRE_INC                                                  $15
    6    18    > > JMP                                                      ->3
         19    >   FE_FREE                                                  $6
   15    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.21 ms | 997 KiB | 14 Q