3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Stick this with your helper functions function buildMenu($navigation, $currentPage){ echo '<ul>'; foreach ($navigation as $key => $val) { $class = $val === $currentPage ? 'on' : 'off'; echo '<li>'; if( is_array($val) ){ echo '<a href="#" class="' . $class . '">' . $key . '</a>'; buildMenu($val, $currentPage); } else { echo '<a href="' . $val . '" class="' . $class . '">' . $key . '</a>'; } echo '</li>'; }; echo '</ul>'; }; // Define current page $currentPage = 'club.php'; // Build up your navigation arrays $navigation = array( 'News' => '#', 'About' => array( 'Club' => 'club.php', 'Coaches' => 'coaches.php', 'Officials' => 'officials.php', 'Management' => 'management.php' ) ); // Build HTML buildMenu($navigation, $currentPage);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/45GT8
function name:  (null)
number of ops:  7
compiled vars:  !0 = $currentPage, !1 = $navigation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, 'club.php'
   23     1        ASSIGN                                                   !1, <array>
   34     2        INIT_FCALL                                               'buildmenu'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function buildmenu:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 34
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 34
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 25
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 25
Branch analysis from position: 15
Branch analysis from position: 25
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/45GT8
function name:  buildMenu
number of ops:  37
compiled vars:  !0 = $navigation, !1 = $currentPage, !2 = $val, !3 = $key, !4 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ECHO                                                     '%3Cul%3E'
    5     3      > FE_RESET_R                                       $5      !0, ->34
          4    > > FE_FETCH_R                                       ~6      $5, !2, ->34
          5    >   ASSIGN                                                   !3, ~6
    6     6        IS_IDENTICAL                                             !2, !1
          7      > JMPZ                                                     ~8, ->10
          8    >   QM_ASSIGN                                        ~9      'on'
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~9      'off'
         11    >   ASSIGN                                                   !4, ~9
    7    12        ECHO                                                     '%3Cli%3E'
    8    13        TYPE_CHECK                                  128          !2
         14      > JMPZ                                                     ~11, ->25
    9    15    >   CONCAT                                           ~12     '%3Ca+href%3D%22%23%22+class%3D%22', !4
         16        CONCAT                                           ~13     ~12, '%22%3E'
         17        CONCAT                                           ~14     ~13, !3
         18        CONCAT                                           ~15     ~14, '%3C%2Fa%3E'
         19        ECHO                                                     ~15
   10    20        INIT_FCALL_BY_NAME                                       'buildMenu'
         21        SEND_VAR_EX                                              !2
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0          
         24      > JMP                                                      ->32
   12    25    >   CONCAT                                           ~17     '%3Ca+href%3D%22', !2
         26        CONCAT                                           ~18     ~17, '%22+class%3D%22'
         27        CONCAT                                           ~19     ~18, !4
         28        CONCAT                                           ~20     ~19, '%22%3E'
         29        CONCAT                                           ~21     ~20, !3
         30        CONCAT                                           ~22     ~21, '%3C%2Fa%3E'
         31        ECHO                                                     ~22
   14    32    >   ECHO                                                     '%3C%2Fli%3E'
    5    33      > JMP                                                      ->4
         34    >   FE_FREE                                                  $5
   16    35        ECHO                                                     '%3C%2Ful%3E'
   17    36      > RETURN                                                   null

End of function buildmenu

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.09 ms | 1407 KiB | 14 Q