3v4l.org

run code in 300+ PHP versions simultaneously
<?php $menu = array( array(1,3,'Wurm 1.1', 2, 10), array(2,6,'Vogel 2.1', 2, 30), array(3,0,'Tiger 1', 1, 10), array(4,6,'Hund 2.2', 2, 40), array(5,3,'Katze 1.2', 2, 11), array(6,0,'Pferd 2', 1, 20), array(7,1,'Baer 1.1.1', 3, 0), array(8,3,'Schwein 1.3', 2, 12), array(9,4,'Esel 2.2.1', 3, 0), ); // Algorithmus hier $items = array(); foreach($menu as $item) { if(!isset($items[$item[1]])) { $items[$item[1]] = array(); } $items[$item[1]][] = $item; } function getChildren($items, $parentId = 0) { return $items[0]; } $result = getChildren($items); var_dump($result); $target = array( array(3,0,'Tiger 1', 1, 10), array(1,3,'Wurm 1.1', 2, 10), array(7,1,'Baer 1.1.1', 3, 0), array(5,3,'Katze 1.2', 2, 11), array(8,3,'Schwein 1.3', 2, 12), array(6,0,'Pferd 2', 1, 20), array(2,6,'Vogel 2.1', 2, 30), array(4,6,'Hund 2.2', 2, 40), array(9,4,'Esel 2.2.1', 3, 0), ); var_dump($result == $target);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/Evufj
function name:  (null)
number of ops:  30
compiled vars:  !0 = $menu, !1 = $items, !2 = $item, !3 = $result, !4 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, <array>
   19     2      > FE_RESET_R                                       $7      !0, ->16
          3    > > FE_FETCH_R                                               $7, !2, ->16
   21     4    >   FETCH_DIM_R                                      ~8      !2, 1
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !1, ~8
          6        BOOL_NOT                                         ~10     ~9
          7      > JMPZ                                                     ~10, ->11
   23     8    >   FETCH_DIM_R                                      ~11     !2, 1
          9        ASSIGN_DIM                                               !1, ~11
         10        OP_DATA                                                  <array>
   26    11    >   FETCH_DIM_R                                      ~13     !2, 1
         12        FETCH_DIM_W                                      $14     !1, ~13
         13        ASSIGN_DIM                                               $14
         14        OP_DATA                                                  !2
   19    15      > JMP                                                      ->3
         16    >   FE_FREE                                                  $7
   34    17        INIT_FCALL                                               'getchildren'
         18        SEND_VAR                                                 !1
         19        DO_FCALL                                      0  $16     
         20        ASSIGN                                                   !3, $16
   35    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                                 
   39    24        ASSIGN                                                   !4, <array>
   51    25        INIT_FCALL                                               'var_dump'
         26        IS_EQUAL                                         ~20     !3, !4
         27        SEND_VAL                                                 ~20
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Function getchildren:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Evufj
function name:  getChildren
number of ops:  5
compiled vars:  !0 = $items, !1 = $parentId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   31     2        FETCH_DIM_R                                      ~2      !0, 0
          3      > RETURN                                                   ~2
   32     4*     > RETURN                                                   null

End of function getchildren

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
128.59 ms | 1407 KiB | 16 Q