3v4l.org

run code in 300+ PHP versions simultaneously
<?php $user = (object)['menu_order' => '1,3,2,4,0']; $menuArray = [ 'Main Street' => [ ['/index.php', 'Home'], ['/city.php', 'MyCity'], ['/travel.php', 'Travel'], ['/bank.php', 'Bank'], ['/inventory.php', 'Inventory'], ['/dailies.php', 'Dailies'], ], 'Activities' => [ (true) ? ['/hospital.php', 'Hospital'] : [], (false) ? ['/crime.php', 'Crime'] : [], ['/missions.php', 'Missions'], ['/achievements.php', 'Achievements'], ], 'Services' => [ ['/hospital.php', 'Hospital'], ['/prison.php', 'Prison'], ['/search.php', 'Search'], ], 'Account' => [ ['/edit_account.php', 'Edit Account'], ['/notepad.php', 'Notepad'], ['/logout.php', 'Logout'], ] ]; function display_menu($menus, $m) { if (!isset($menus[$m])) return; echo "<ul>"; foreach ($menus[$m] as $item) { if (!count($item)) continue; echo "<li><a href=\"{$item[0]}\">{$item[1]}</a>\n"; } echo "</ul>"; } $menuMap = array(0 => 'Main Street', 1 => 'Activities', 2 => 'Services', 3 => 'Account', 4 => 'Communication'); $menuOrder = explode(',', $user->menu_order); foreach ($menuOrder as $menuIndex) { $thisMenu = $menuMap[$menuIndex]; display_menu($menuArray, $thisMenu); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/ZEKFe
function name:  (null)
number of ops:  21
compiled vars:  !0 = $user, !1 = $menuArray, !2 = $menuMap, !3 = $menuOrder, !4 = $menuIndex, !5 = $thisMenu
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   CAST                                          8  ~6      <array>
          1        ASSIGN                                                   !0, ~6
    3     2        ASSIGN                                                   !1, <array>
   38     3        ASSIGN                                                   !2, <array>
   43     4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%2C'
          6        FETCH_OBJ_R                                      ~10     !0, 'menu_order'
          7        SEND_VAL                                                 ~10
          8        DO_ICALL                                         $11     
          9        ASSIGN                                                   !3, $11
   44    10      > FE_RESET_R                                       $13     !3, ->19
         11    > > FE_FETCH_R                                               $13, !4, ->19
   45    12    >   FETCH_DIM_R                                      ~14     !2, !4
         13        ASSIGN                                                   !5, ~14
   46    14        INIT_FCALL                                               'display_menu'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !5
         17        DO_FCALL                                      0          
   44    18      > JMP                                                      ->11
         19    >   FE_FREE                                                  $13
   47    20      > RETURN                                                   1

Function display_menu:
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
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/ZEKFe
function name:  display_menu
number of ops:  26
compiled vars:  !0 = $menus, !1 = $m, !2 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   30     2        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !0, !1
          3        BOOL_NOT                                         ~4      ~3
          4      > JMPZ                                                     ~4, ->6
          5    > > RETURN                                                   null
   31     6    >   ECHO                                                     '%3Cul%3E'
   32     7        FETCH_DIM_R                                      ~5      !0, !1
          8      > FE_RESET_R                                       $6      ~5, ->23
          9    > > FE_FETCH_R                                               $6, !2, ->23
   33    10    >   COUNT                                            ~7      !2
         11        BOOL_NOT                                         ~8      ~7
         12      > JMPZ                                                     ~8, ->14
         13    > > JMP                                                      ->9
   34    14    >   ROPE_INIT                                     5  ~12     '%3Cli%3E%3Ca+href%3D%22'
         15        FETCH_DIM_R                                      ~9      !2, 0
         16        ROPE_ADD                                      1  ~12     ~12, ~9
         17        ROPE_ADD                                      2  ~12     ~12, '%22%3E'
         18        FETCH_DIM_R                                      ~10     !2, 1
         19        ROPE_ADD                                      3  ~12     ~12, ~10
         20        ROPE_END                                      4  ~11     ~12, '%3C%2Fa%3E%0A'
         21        ECHO                                                     ~11
   32    22      > JMP                                                      ->9
         23    >   FE_FREE                                                  $6
   36    24        ECHO                                                     '%3C%2Ful%3E'
   37    25      > RETURN                                                   null

End of function display_menu

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
204.41 ms | 1007 KiB | 15 Q