3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( array ( 'name' => 'menus', 'route' => 'admin.menu', 'parent_id' => null, ), array ( 'name' => 'users', 'route' => 'users', 'parent_id' => 0, ), array ( 'name' => 'roles', 'route' => 'roles', 'parent_id' => 0, ), array ( 'name' => 'testmenu-3', 'route' => 'testmenu-3', 'parent_id' => 1, ), array ( 'name' => 'testmenu-5', 'route' => 'testmenu-5', 'parent_id' => 1, ), array ( 'name' => 'testmenu-6', 'route' => 'testmenu-6', 'parent_id' => 0, ) ); $keys = array_keys($array); array_multisort( array_column($array, 'parent_id'), SORT_ASC, SORT_NUMERIC, $array, $keys ); $array = array_combine($keys, $array); $parent = $array[0]['name']; $out = array(); $pid = 0; $space = ''; unset($array[0]); foreach($array as $key => $val){ if($pid != $val['parent_id']){ $pid = $val['parent_id']; $space .= '&nbsp;&nbsp;&nbsp;&nbsp;'; } echo $space.$val['name']."<br/>"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 42
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 42
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 37
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/FICIY
function name:  (null)
number of ops:  44
compiled vars:  !0 = $array, !1 = $keys, !2 = $parent, !3 = $out, !4 = $pid, !5 = $space, !6 = $val, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   37     1        INIT_FCALL                                               'array_keys'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $9      
          4        ASSIGN                                                   !1, $9
   38     5        INIT_FCALL                                               'array_multisort'
   39     6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'parent_id'
          9        DO_ICALL                                         $11     
         10        SEND_VAL                                                 $11
         11        SEND_VAL                                                 4
         12        SEND_VAL                                                 1
         13        SEND_REF                                                 !0
         14        SEND_REF                                                 !1
   38    15        DO_ICALL                                                 
   41    16        INIT_FCALL                                               'array_combine'
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !0, $13
   43    21        FETCH_DIM_R                                      ~15     !0, 0
         22        FETCH_DIM_R                                      ~16     ~15, 'name'
         23        ASSIGN                                                   !2, ~16
   44    24        ASSIGN                                                   !3, <array>
   46    25        ASSIGN                                                   !4, 0
   47    26        ASSIGN                                                   !5, ''
   48    27        UNSET_DIM                                                !0, 0
   49    28      > FE_RESET_R                                       $21     !0, ->42
         29    > > FE_FETCH_R                                       ~22     $21, !6, ->42
         30    >   ASSIGN                                                   !7, ~22
   50    31        FETCH_DIM_R                                      ~24     !6, 'parent_id'
         32        IS_NOT_EQUAL                                             !4, ~24
         33      > JMPZ                                                     ~25, ->37
   51    34    >   FETCH_DIM_R                                      ~26     !6, 'parent_id'
         35        ASSIGN                                                   !4, ~26
   52    36        ASSIGN_OP                                     8          !5, '%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B'
   54    37    >   FETCH_DIM_R                                      ~29     !6, 'name'
         38        CONCAT                                           ~30     !5, ~29
         39        CONCAT                                           ~31     ~30, '%3Cbr%2F%3E'
         40        ECHO                                                     ~31
   49    41      > JMP                                                      ->29
         42    >   FE_FREE                                                  $21
   55    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
316.54 ms | 1018 KiB | 17 Q