3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['App', 'Classes', 'Auth'], ['App', 'Classes', 'Auth'], ['App', 'Classes', 'Middleware'], ['App', 'Classes', 'Phone'], ['App', 'Classes', 'Auth'], ['App', 'Mail'], ['App', 'Mail', 'Sender'], ['App', 'Box'], ]; $results = json_decode(json_encode($array)); $tree = null; foreach ($results as $result) { $thisref = &$refs->{$result[0]}; $tree->{$result[0]} = &$thisref; $thisref = &$refs->{$result[1]}; $tree->{$result[0]}->{$result[1]} = &$thisref; if (!empty($result[2])) { $thisref = &$refs->{$result[2]}; $refs->{$result[0]}->{$result[1]}[] = $result[2];//&$thisref; $refs->{$result[0]}->{$result[1]} = array_unique($refs->{$result[0]}->{$result[1]}); } } print_r(json_decode(json_encode($tree), true));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 51
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 51
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 50
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 50
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
filename:       /in/2udcX
function name:  (null)
number of ops:  63
compiled vars:  !0 = $array, !1 = $results, !2 = $tree, !3 = $result, !4 = $thisref, !5 = $refs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'json_decode'
          2        INIT_FCALL                                               'json_encode'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        SEND_VAR                                                 $7
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
   13     8        ASSIGN                                                   !2, null
   14     9      > FE_RESET_R                                       $11     !1, ->51
         10    > > FE_FETCH_R                                               $11, !3, ->51
   15    11    >   FETCH_DIM_R                                      ~12     !3, 0
         12        FETCH_OBJ_W                                      $13     !5, ~12
         13        ASSIGN_REF                                               !4, $13
   16    14        FETCH_DIM_R                                      ~15     !3, 0
         15        ASSIGN_OBJ_REF                                           !2, ~15
         16        OP_DATA                                                  !4
   17    17        FETCH_DIM_R                                      ~17     !3, 1
         18        FETCH_OBJ_W                                      $18     !5, ~17
         19        ASSIGN_REF                                               !4, $18
   18    20        FETCH_DIM_R                                      ~20     !3, 0
         21        FETCH_DIM_R                                      ~22     !3, 1
         22        FETCH_OBJ_W                                      $21     !2, ~20
         23        ASSIGN_OBJ_REF                                           $21, ~22
         24        OP_DATA                                                  !4
   19    25        ISSET_ISEMPTY_DIM_OBJ                         1  ~24     !3, 2
         26        BOOL_NOT                                         ~25     ~24
         27      > JMPZ                                                     ~25, ->50
   20    28    >   FETCH_DIM_R                                      ~26     !3, 2
         29        FETCH_OBJ_W                                      $27     !5, ~26
         30        ASSIGN_REF                                               !4, $27
   21    31        FETCH_DIM_R                                      ~29     !3, 0
         32        FETCH_DIM_R                                      ~31     !3, 1
         33        FETCH_DIM_R                                      ~34     !3, 2
         34        FETCH_OBJ_W                                      $30     !5, ~29
         35        FETCH_OBJ_W                                      $32     $30, ~31
         36        ASSIGN_DIM                                               $32
         37        OP_DATA                                                  ~34
   22    38        FETCH_DIM_R                                      ~35     !3, 0
         39        FETCH_DIM_R                                      ~37     !3, 1
         40        INIT_FCALL                                               'array_unique'
         41        FETCH_DIM_R                                      ~39     !3, 0
         42        FETCH_DIM_R                                      ~41     !3, 1
         43        FETCH_OBJ_R                                      ~40     !5, ~39
         44        FETCH_OBJ_R                                      ~42     ~40, ~41
         45        SEND_VAL                                                 ~42
         46        DO_ICALL                                         $43     
         47        FETCH_OBJ_W                                      $36     !5, ~35
         48        ASSIGN_OBJ                                               $36, ~37
         49        OP_DATA                                                  $43
   14    50    > > JMP                                                      ->10
         51    >   FE_FREE                                                  $11
   26    52        INIT_FCALL                                               'print_r'
         53        INIT_FCALL                                               'json_decode'
         54        INIT_FCALL                                               'json_encode'
         55        SEND_VAR                                                 !2
         56        DO_ICALL                                         $44     
         57        SEND_VAR                                                 $44
         58        SEND_VAL                                                 <true>
         59        DO_ICALL                                         $45     
         60        SEND_VAR                                                 $45
         61        DO_ICALL                                                 
         62      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.68 ms | 1400 KiB | 21 Q