3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array( 'id' => 1, 'parent_id' => 0, 'title' => 'Parent Page', 'children' => array( array( 'id' => 2, 'parent_id' => 1, 'title' => 'Sub Page', ), array( 'id' => 5, 'parent_id' => 1, 'title' => 'Sub Page 2', 'children' => array( array( 'id' => 7, 'parent_id' => 5, 'title' => 'Sub Page', ), array( 'id' => 8, 'parent_id' => 5, 'title' => 'Sub Page 2', ) ) ) ) ), array( 'id' => 4, 'parent_id' => 0, 'title' => 'Another Parent Page', ) ); function printAll($arr, $parent = []) { if (is_array($arr)) { foreach ($arr as $k => $v) { if (isset($v['id'])) { $parent[] = $v['id']; echo implode('.', $parent) . PHP_EOL; } if (isset($v['children'])) { printAll($v['children'], $parent); } array_pop($parent); } } } printAll($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IANDm
function name:  (null)
number of ops:  5
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   53     1        INIT_FCALL                                               'printall'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function printall:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 31
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 30
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 30
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 26
Branch analysis from position: 18
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 31
filename:       /in/IANDm
function name:  printAll
number of ops:  32
compiled vars:  !0 = $arr, !1 = $parent, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   40     2        TYPE_CHECK                                  128          !0
          3      > JMPZ                                                     ~4, ->31
   41     4    > > FE_RESET_R                                       $5      !0, ->30
          5    > > FE_FETCH_R                                       ~6      $5, !2, ->30
          6    >   ASSIGN                                                   !3, ~6
   42     7        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 'id'
          8      > JMPZ                                                     ~8, ->18
   43     9    >   FETCH_DIM_R                                      ~10     !2, 'id'
         10        ASSIGN_DIM                                               !1
         11        OP_DATA                                                  ~10
   44    12        INIT_FCALL                                               'implode'
         13        SEND_VAL                                                 '.'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $11     
         16        CONCAT                                           ~12     $11, '%0A'
         17        ECHO                                                     ~12
   46    18    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, 'children'
         19      > JMPZ                                                     ~13, ->26
   47    20    >   INIT_FCALL_BY_NAME                                       'printAll'
         21        CHECK_FUNC_ARG                                           
         22        FETCH_DIM_FUNC_ARG                               $14     !2, 'children'
         23        SEND_FUNC_ARG                                            $14
         24        SEND_VAR_EX                                              !1
         25        DO_FCALL                                      0          
   49    26    >   INIT_FCALL                                               'array_pop'
         27        SEND_REF                                                 !1
         28        DO_ICALL                                                 
   41    29      > JMP                                                      ->5
         30    >   FE_FREE                                                  $5
   52    31    > > RETURN                                                   null

End of function printall

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.68 ms | 1445 KiB | 16 Q