3v4l.org

run code in 300+ PHP versions simultaneously
<?php $datas = array( array('id' => 1, 'parent' => 0, 'name' => 'Page 1'), array('id' => 2, 'parent' => 1, 'name' => 'Page 1.1'), array('id' => 3, 'parent' => 2, 'name' => 'Page 1.1.1'), array('id' => 4, 'parent' => 3, 'name' => 'Page 1.1.1.1'), array('id' => 5, 'parent' => 3, 'name' => 'Page 1.1.1.2'), array('id' => 6, 'parent' => 1, 'name' => 'Page 1.2'), array('id' => 7, 'parent' => 6, 'name' => 'Page 1.2.1'), array('id' => 8, 'parent' => 0, 'name' => 'Page 2'), array('id' => 9, 'parent' => 0, 'name' => 'Page 3'), array('id' => 10, 'parent' => 9, 'name' => 'Page 3.1'), array('id' => 11, 'parent' => 9, 'name' => 'Page 3.2'), array('id' => 12, 'parent' => 11, 'name' => 'Page 3.2.1'), ); function generatePageTree($datas, $parent = 0, $limit=0){ if($limit > 1000) return ''; // Make sure not to have an endless recursion $tree = '<ul>'; for($i=0, $ni=count($datas); $i < $ni; $i++){ if($datas[$i]['parent'] == $parent){ $tree .= '<li>'; $tree .= $datas[$i]['name']; $tree .= generatePageTree($datas, $datas[$i]['id'], $limit++); $tree .= '</li>'; } } $tree .= '</ul>'; return $tree; } echo(generatePageTree($datas)); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vCJQl
function name:  (null)
number of ops:  6
compiled vars:  !0 = $datas
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   32     1        INIT_FCALL                                               'generatepagetree'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
   34     5      > RETURN                                                   1

Function generatepagetree:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 11
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 11
Branch analysis from position: 33
Branch analysis from position: 11
Branch analysis from position: 30
filename:       /in/vCJQl
function name:  generatePageTree
number of ops:  36
compiled vars:  !0 = $datas, !1 = $parent, !2 = $limit, !3 = $tree, !4 = $i, !5 = $ni
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      0
   18     3        IS_SMALLER                                               1000, !2
          4      > JMPZ                                                     ~6, ->6
          5    > > RETURN                                                   ''
   19     6    >   ASSIGN                                                   !3, '%3Cul%3E'
   20     7        ASSIGN                                                   !4, 0
          8        COUNT                                            ~9      !0
          9        ASSIGN                                                   !5, ~9
         10      > JMP                                                      ->31
   21    11    >   FETCH_DIM_R                                      ~11     !0, !4
         12        FETCH_DIM_R                                      ~12     ~11, 'parent'
         13        IS_EQUAL                                                 !1, ~12
         14      > JMPZ                                                     ~13, ->30
   22    15    >   ASSIGN_OP                                     8          !3, '%3Cli%3E'
   23    16        FETCH_DIM_R                                      ~15     !0, !4
         17        FETCH_DIM_R                                      ~16     ~15, 'name'
         18        ASSIGN_OP                                     8          !3, ~16
   24    19        INIT_FCALL_BY_NAME                                       'generatePageTree'
         20        SEND_VAR_EX                                              !0
         21        CHECK_FUNC_ARG                                           
         22        FETCH_DIM_FUNC_ARG                               $18     !0, !4
         23        FETCH_DIM_FUNC_ARG                               $19     $18, 'id'
         24        SEND_FUNC_ARG                                            $19
         25        POST_INC                                         ~20     !2
         26        SEND_VAL_EX                                              ~20
         27        DO_FCALL                                      0  $21     
         28        ASSIGN_OP                                     8          !3, $21
   25    29        ASSIGN_OP                                     8          !3, '%3C%2Fli%3E'
   20    30    >   PRE_INC                                                  !4
         31    >   IS_SMALLER                                               !4, !5
         32      > JMPNZ                                                    ~25, ->11
   28    33    >   ASSIGN_OP                                     8          !3, '%3C%2Ful%3E'
   29    34      > RETURN                                                   !3
   30    35*     > RETURN                                                   null

End of function generatepagetree

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.15 ms | 1403 KiB | 14 Q