3v4l.org

run code in 300+ PHP versions simultaneously
<?php // result from query: SELECT * FROM depts $depts = array( array( // row #0 'deptid' => 1, 'dept_code' => '1', 'dept_name' => 'wadir Umum', 'parent_deptid' => 0, ), array( // row #1 'deptid' => 2, 'dept_code' => '101', 'dept_name' => 'bagian umum', 'parent_deptid' => 1, ), array( // row #2 'deptid' => 3, 'dept_code' => '10101', 'dept_name' => 'kepala umum', 'parent_deptid' => 2, ), array( // row #3 'deptid' => 4, 'dept_code' => '102', 'dept_name' => 'bagian privasi', 'parent_deptid' => 1, ), array( // row #4 'deptid' => 5, 'dept_code' => '1010101', 'dept_name' => 'SUb bagian Tu', 'parent_deptid' => 3, ), array( // row #5 'deptid' => 6, 'dept_code' => '1010102', 'dept_name' => 'bagian umum', 'parent_deptid' => 3, ), ); $nodes = array(); $roots = array(); // init nodes foreach ($depts as $dept) { $dept['childs'] = array(); // init childs $nodes[$dept['deptid']] = $dept; } foreach ($depts as $dept) { if ($dept['parent_deptid'] == 0) { $roots[] = $dept['deptid']; // add root } else { $nodes[$dept['parent_deptid']]['childs'][] = $dept['deptid']; // add to parents chlids list } } var_export($roots); echo "\n\n"; var_export($nodes); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 28
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 28
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 11
filename:       /in/YkAr0
function name:  (null)
number of ops:  37
compiled vars:  !0 = $depts, !1 = $nodes, !2 = $roots, !3 = $dept
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   44     1        ASSIGN                                                   !1, <array>
   45     2        ASSIGN                                                   !2, <array>
   48     3      > FE_RESET_R                                       $7      !0, ->11
          4    > > FE_FETCH_R                                               $7, !3, ->11
   49     5    >   ASSIGN_DIM                                               !3, 'childs'
          6        OP_DATA                                                  <array>
   50     7        FETCH_DIM_R                                      ~9      !3, 'deptid'
          8        ASSIGN_DIM                                               !1, ~9
          9        OP_DATA                                                  !3
   48    10      > JMP                                                      ->4
         11    >   FE_FREE                                                  $7
   54    12      > FE_RESET_R                                       $11     !0, ->28
         13    > > FE_FETCH_R                                               $11, !3, ->28
   55    14    >   FETCH_DIM_R                                      ~12     !3, 'parent_deptid'
         15        IS_EQUAL                                                 ~12, 0
         16      > JMPZ                                                     ~13, ->21
   56    17    >   FETCH_DIM_R                                      ~15     !3, 'deptid'
         18        ASSIGN_DIM                                               !2
         19        OP_DATA                                                  ~15
   55    20      > JMP                                                      ->27
   58    21    >   FETCH_DIM_R                                      ~16     !3, 'parent_deptid'
         22        FETCH_DIM_R                                      ~20     !3, 'deptid'
         23        FETCH_DIM_W                                      $17     !1, ~16
         24        FETCH_DIM_W                                      $18     $17, 'childs'
         25        ASSIGN_DIM                                               $18
         26        OP_DATA                                                  ~20
   54    27    > > JMP                                                      ->13
         28    >   FE_FREE                                                  $11
   62    29        INIT_FCALL                                               'var_export'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                                 
   63    32        ECHO                                                     '%0A%0A'
   64    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                                 
   66    36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.34 ms | 1003 KiB | 14 Q