3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tree = [ '' => function () { return [ 1 ]; }, 1 => function () { return [ 2, 3, 4 ]; }, 2 => function () { return [ 5, 6 ]; }, 3 => function () { return [ 7, 8 ]; }, ]; $queue = new \SplQueue(); $queue->enqueue([ '', 0 ]); while ( ! $queue->isEmpty() ) { [ $parent, $level ] = $queue->dequeue(); echo str_repeat(' ', $level) . $parent . PHP_EOL; $children = isset($tree[ $parent ]) ? $tree[ $parent ]() : []; foreach ( $children as $child ) { $queue->enqueue([ $child, $level + 1 ]); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 16
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 48
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 48
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 16
Branch analysis from position: 53
Branch analysis from position: 16
Branch analysis from position: 48
Branch analysis from position: 37
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 48
Branch analysis from position: 40
Branch analysis from position: 48
filename:       /in/LP1id
function name:  (null)
number of ops:  54
compiled vars:  !0 = $tree, !1 = $queue, !2 = $parent, !3 = $level, !4 = $children, !5 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          1        INIT_ARRAY                                       ~7      ~6, ''
    5     2        DECLARE_LAMBDA_FUNCTION                          ~8      [1]
          3        ADD_ARRAY_ELEMENT                                ~7      ~8, 1
    6     4        DECLARE_LAMBDA_FUNCTION                          ~9      [2]
          5        ADD_ARRAY_ELEMENT                                ~7      ~9, 2
    7     6        DECLARE_LAMBDA_FUNCTION                          ~10     [3]
          7        ADD_ARRAY_ELEMENT                                ~7      ~10, 3
    3     8        ASSIGN                                                   !0, ~7
   10     9        NEW                                              $12     'SplQueue'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $12
   12    12        INIT_METHOD_CALL                                         !1, 'enqueue'
         13        SEND_VAL_EX                                              <array>
         14        DO_FCALL                                      0          
   14    15      > JMP                                                      ->49
   15    16    >   INIT_METHOD_CALL                                         !1, 'dequeue'
         17        DO_FCALL                                      0  $16     
         18        FETCH_LIST_R                                     $17     $16, 0
         19        ASSIGN                                                   !2, $17
         20        FETCH_LIST_R                                     $19     $16, 1
         21        ASSIGN                                                   !3, $19
         22        FREE                                                     $16
   16    23        INIT_FCALL                                               'str_repeat'
         24        SEND_VAL                                                 '++'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                         $21     
         27        CONCAT                                           ~22     $21, !2
         28        CONCAT                                           ~23     ~22, '%0A'
         29        ECHO                                                     ~23
   18    30        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
         31      > JMPZ                                                     ~24, ->37
         32    >   FETCH_DIM_R                                      ~25     !0, !2
         33        INIT_DYNAMIC_CALL                                        ~25
         34        DO_FCALL                                      0  $26     
         35        QM_ASSIGN                                        ~27     $26
         36      > JMP                                                      ->38
         37    >   QM_ASSIGN                                        ~27     <array>
         38    >   ASSIGN                                                   !4, ~27
   19    39      > FE_RESET_R                                       $29     !4, ->48
         40    > > FE_FETCH_R                                               $29, !5, ->48
   20    41    >   INIT_METHOD_CALL                                         !1, 'enqueue'
         42        INIT_ARRAY                                       ~30     !5
         43        ADD                                              ~31     !3, 1
         44        ADD_ARRAY_ELEMENT                                ~30     ~31
         45        SEND_VAL_EX                                              ~30
         46        DO_FCALL                                      0          
   19    47      > JMP                                                      ->40
         48    >   FE_FREE                                                  $29
   14    49    >   INIT_METHOD_CALL                                         !1, 'isEmpty'
         50        DO_FCALL                                      0  $33     
         51        BOOL_NOT                                         ~34     $33
         52      > JMPNZ                                                    ~34, ->16
   22    53    > > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LP1id
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   <array>
          1*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LP1id
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   <array>
          1*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LP1id
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   <array>
          1*     > RETURN                                                   null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LP1id
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   <array>
          1*     > RETURN                                                   null

End of Dynamic Function 3

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.82 ms | 1014 KiB | 14 Q