3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lists = array(array( array( 'id' => 1, 'parent' => 0, 'name' => 'Menu 1', ), array( 'id' => 2, 'parent' => 1, 'name' => 'Menu 2', ), array( 'id' => 3, 'parent' => 2, 'name' => 'Menu 3', ), array( 'id' => 4, 'parent' => 1, 'name' => 'Menu 4', ), array( 'id' => 5, 'parent' => 0, 'name' => 'Menu 5', ) )); function make_list($lists, $parent = 0) { $children = array_filter($lists[0], function ($v) use($parent) { return $v['parent'] == $parent; }); if (!count($children)) return; echo "<ul>\n"; foreach ($children as $child) { echo "<li>{$child['name']}</li>\n"; make_list($lists, $child['id']); } echo "</ul>\n"; } make_list($lists);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hZ07j
function name:  (null)
number of ops:  5
compiled vars:  !0 = $lists
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   40     1        INIT_FCALL                                               'make_list'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function make_list:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 29
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/hZ07j
function name:  make_list
number of ops:  32
compiled vars:  !0 = $lists, !1 = $parent, !2 = $children, !3 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   30     2        INIT_FCALL                                               'array_filter'
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        SEND_VAL                                                 ~4
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhZ07j%3A30%240'
          6        BIND_LEXICAL                                             ~5, !1
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   31    10        COUNT                                            ~8      !2
         11        BOOL_NOT                                         ~9      ~8
         12      > JMPZ                                                     ~9, ->14
         13    > > RETURN                                                   null
   32    14    >   ECHO                                                     '%3Cul%3E%0A'
   33    15      > FE_RESET_R                                       $10     !2, ->29
         16    > > FE_FETCH_R                                               $10, !3, ->29
   34    17    >   ROPE_INIT                                     3  ~13     '%3Cli%3E'
         18        FETCH_DIM_R                                      ~11     !3, 'name'
         19        ROPE_ADD                                      1  ~13     ~13, ~11
         20        ROPE_END                                      2  ~12     ~13, '%3C%2Fli%3E%0A'
         21        ECHO                                                     ~12
   35    22        INIT_FCALL_BY_NAME                                       'make_list'
         23        SEND_VAR_EX                                              !0
         24        CHECK_FUNC_ARG                                           
         25        FETCH_DIM_FUNC_ARG                               $15     !3, 'id'
         26        SEND_FUNC_ARG                                            $15
         27        DO_FCALL                                      0          
   33    28      > JMP                                                      ->16
         29    >   FE_FREE                                                  $10
   37    30        ECHO                                                     '%3C%2Ful%3E%0A'
   38    31      > RETURN                                                   null

End of function make_list

Function %00%7Bclosure%7D%2Fin%2FhZ07j%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hZ07j
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $v, !1 = $parent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 'parent'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FhZ07j%3A30%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.79 ms | 1394 KiB | 16 Q