3v4l.org

run code in 300+ PHP versions simultaneously
<?php function makeNav($item) { $ret = '<li><a href="'.$item['url'].'">'.$item['name'].'</a>'.PHP_EOL; if (isset($item['subPgs']) && is_array($item['subPgs']) && count($item['subPgs']) > 0) { $ret .= '<ul>'.PHP_EOL; foreach ($item['subPgs'] as $subPg) { $ret .= makeNav($subPg); } $ret .= '</ul>'.PHP_EOL; } else { $ret .= '</li>'.PHP_EOL; } if (isset($item['subPgs']) && is_array($item['subPgs']) && count($item['subPgs']) > 0) { $ret .= "</li>".PHP_EOL; } return $ret; } $navItems = array( /*array( 'name' => 'Home', 'url' => '#', 'subPgs'=>array() ),*/ array( 'name' => 'Parent', 'url' => '#', 'subPgs' => array( array( 'name' => 'Child', 'url' => '#', 'subPgs' => array( array( 'name' => 'Grand Child', 'url' => '#' ), array( 'name' => 'Grand Child', 'url' => '#', 'subPgs' => array( array( 'name' => 'Grand Child Child', 'url' => '#' ), array( 'name' => 'Grand Child Child', 'url' => '#' ) ) ) ) ), array( 'name' => 'Child', 'url' => '#', 'subPgs' => array( array( 'name' => 'Grand Child', 'url' => '#', 'subPgs' => array( array( 'name' => 'Grand Grand Child', 'url' => '#' ) ) ), array( 'name' => 'Grand Child', 'url' => '#' ) ) ) ) ) ); $nav = '<ul>'; foreach ($navItems as $navItem) { $nav .= makeNav($navItem); } echo $nav.'</ul>'; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/O4i2t
function name:  (null)
number of ops:  13
compiled vars:  !0 = $navItems, !1 = $nav, !2 = $navItem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   80     1        ASSIGN                                                   !1, '%3Cul%3E'
   81     2      > FE_RESET_R                                       $5      !0, ->9
          3    > > FE_FETCH_R                                               $5, !2, ->9
   82     4    >   INIT_FCALL                                               'makenav'
          5        SEND_VAR                                                 !2
          6        DO_FCALL                                      0  $6      
          7        ASSIGN_OP                                     8          !1, $6
   81     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $5
   84    10        CONCAT                                           ~8      !1, '%3C%2Ful%3E'
         11        ECHO                                                     ~8
   85    12      > RETURN                                                   1

Function makenav:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 32
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 46) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 45
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 43
Branch analysis from position: 38
Branch analysis from position: 29
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
Branch analysis from position: 38
Branch analysis from position: 19
Branch analysis from position: 14
filename:       /in/O4i2t
function name:  makeNav
number of ops:  47
compiled vars:  !0 = $item, !1 = $ret, !2 = $subPg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        FETCH_DIM_R                                      ~3      !0, 'url'
          2        CONCAT                                           ~4      '%3Cli%3E%3Ca+href%3D%22', ~3
          3        CONCAT                                           ~5      ~4, '%22%3E'
          4        FETCH_DIM_R                                      ~6      !0, 'name'
          5        CONCAT                                           ~7      ~5, ~6
          6        CONCAT                                           ~8      ~7, '%3C%2Fa%3E'
          7        CONCAT                                           ~9      ~8, '%0A'
          8        ASSIGN                                                   !1, ~9
    5     9        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !0, 'subPgs'
         10      > JMPZ_EX                                          ~11     ~11, ->14
         11    >   FETCH_DIM_R                                      ~12     !0, 'subPgs'
         12        TYPE_CHECK                                  128  ~13     ~12
         13        BOOL                                             ~11     ~13
         14    > > JMPZ_EX                                          ~11     ~11, ->19
         15    >   FETCH_DIM_R                                      ~14     !0, 'subPgs'
         16        COUNT                                            ~15     ~14
         17        IS_SMALLER                                       ~16     0, ~15
         18        BOOL                                             ~11     ~16
         19    > > JMPZ                                                     ~11, ->32
    6    20    >   ASSIGN_OP                                     8          !1, '%3Cul%3E%0A'
    7    21        FETCH_DIM_R                                      ~18     !0, 'subPgs'
         22      > FE_RESET_R                                       $19     ~18, ->29
         23    > > FE_FETCH_R                                               $19, !2, ->29
    8    24    >   INIT_FCALL_BY_NAME                                       'makeNav'
         25        SEND_VAR_EX                                              !2
         26        DO_FCALL                                      0  $20     
         27        ASSIGN_OP                                     8          !1, $20
    7    28      > JMP                                                      ->23
         29    >   FE_FREE                                                  $19
   10    30        ASSIGN_OP                                     8          !1, '%3C%2Ful%3E%0A'
         31      > JMP                                                      ->33
   12    32    >   ASSIGN_OP                                     8          !1, '%3C%2Fli%3E%0A'
   15    33    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~24     !0, 'subPgs'
         34      > JMPZ_EX                                          ~24     ~24, ->38
         35    >   FETCH_DIM_R                                      ~25     !0, 'subPgs'
         36        TYPE_CHECK                                  128  ~26     ~25
         37        BOOL                                             ~24     ~26
         38    > > JMPZ_EX                                          ~24     ~24, ->43
         39    >   FETCH_DIM_R                                      ~27     !0, 'subPgs'
         40        COUNT                                            ~28     ~27
         41        IS_SMALLER                                       ~29     0, ~28
         42        BOOL                                             ~24     ~29
         43    > > JMPZ                                                     ~24, ->45
   16    44    >   ASSIGN_OP                                     8          !1, '%3C%2Fli%3E%0A'
   19    45    > > RETURN                                                   !1
   20    46*     > RETURN                                                   null

End of function makenav

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.9 ms | 1407 KiB | 14 Q