3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = array( array('sn' => 1, 'name' => 'Clement', 'upper' => 0), array('sn' => 2, 'name' => 'Jean', 'upper' => 1), array('sn' => 3, 'name' => 'Annie', 'upper' => 1), array('sn' => 4, 'name' => 'Yuan', 'upper' => 2), array('sn' => 5, 'name' => 'Mei', 'upper' => 2), array('sn' => 6, 'name' => 'Blue', 'upper' => 3), array('sn' => 7, 'name' => 'Yang', 'upper' => 5), array('sn' => 8, 'name' => 'Lorinda', 'upper' => 0), ); $map = array(); foreach ($input as $node) { // init self if (!array_key_exists($node['sn'], $map)) { $map[$node['sn']] = array('self' => $node['name']); } else { $map[$node['sn']]['self'] = $node['name']; } // init parent if (!array_key_exists($node['upper'], $map)) { $map[$node['upper']] = array(); } // add to parent $map[$node['upper']][$node['sn']] = & $map[$node['sn']]; } print_r($map[0]);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 35
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 35
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
Branch analysis from position: 26
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/vuVPu
function name:  (null)
number of ops:  41
compiled vars:  !0 = $input, !1 = $map, !2 = $node
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   13     1        ASSIGN                                                       !1, <array>
   15     2      > FE_RESET_R                                           $5      !0, ->35
          3    > > FE_FETCH_R                                                   $5, !2, ->35
   17     4    >   FETCH_DIM_R                                          ~6      !2, 'sn'
          5        ARRAY_KEY_EXISTS                                     ~7      ~6, !1
          6        BOOL_NOT                                             ~8      ~7
          7      > JMPZ                                                         ~8, ->14
   18     8    >   FETCH_DIM_R                                          ~9      !2, 'sn'
          9        FETCH_DIM_R                                          ~11     !2, 'name'
         10        INIT_ARRAY                                           ~12     ~11, 'self'
         11        ASSIGN_DIM                                                   !1, ~9
         12        OP_DATA                                                      ~12
   17    13      > JMP                                                          ->19
   21    14    >   FETCH_DIM_R                                          ~13     !2, 'sn'
         15        FETCH_DIM_R                                          ~16     !2, 'name'
         16        FETCH_DIM_W                                          $14     !1, ~13
         17        ASSIGN_DIM                                                   $14, 'self'
         18        OP_DATA                                                      ~16
   25    19    >   FETCH_DIM_R                                          ~17     !2, 'upper'
         20        ARRAY_KEY_EXISTS                                     ~18     ~17, !1
         21        BOOL_NOT                                             ~19     ~18
         22      > JMPZ                                                         ~19, ->26
   26    23    >   FETCH_DIM_R                                          ~20     !2, 'upper'
         24        ASSIGN_DIM                                                   !1, ~20
         25        OP_DATA                                                      <array>
   30    26    >   FETCH_DIM_R                                          ~22     !2, 'upper'
         27        FETCH_DIM_R                                          ~24     !2, 'sn'
         28        FETCH_DIM_R                                          ~26     !2, 'sn'
         29        FETCH_DIM_W                                          $27     !1, ~26
         30        MAKE_REF                                             $28     $27
         31        FETCH_DIM_W                                          $23     !1, ~22
         32        FETCH_DIM_W                                          $25     $23, ~24
         33        ASSIGN_REF                                                   $25, $28
   15    34      > JMP                                                          ->3
         35    >   FE_FREE                                                      $5
   33    36        INIT_FCALL                                                   'print_r'
         37        FETCH_DIM_R                                          ~30     !1, 0
         38        SEND_VAL                                                     ~30
         39        DO_ICALL                                                     
         40      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
218.53 ms | 3548 KiB | 14 Q