3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array( array('id' => 2, 'name' => 'Clement', 'upper' => 0), array('id' => 1, 'name' => 'Jean', 'upper' => 1), array('id' => 1, 'name' => 'Annie', 'upper' => 1) ); $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/LJN4H
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>
    8     1        ASSIGN                                                   !1, <array>
   10     2      > FE_RESET_R                                       $5      !0, ->35
          3    > > FE_FETCH_R                                               $5, !2, ->35
   12     4    >   FETCH_DIM_R                                      ~6      !2, 'sn'
          5        ARRAY_KEY_EXISTS                                 ~7      ~6, !1
          6        BOOL_NOT                                         ~8      ~7
          7      > JMPZ                                                     ~8, ->14
   13     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
         13      > JMP                                                      ->19
   16    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
   20    19    >   FETCH_DIM_R                                      ~17     !2, 'upper'
         20        ARRAY_KEY_EXISTS                                 ~18     ~17, !1
         21        BOOL_NOT                                         ~19     ~18
         22      > JMPZ                                                     ~19, ->26
   21    23    >   FETCH_DIM_R                                      ~20     !2, 'upper'
         24        ASSIGN_DIM                                               !1, ~20
         25        OP_DATA                                                  <array>
   25    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
   10    34      > JMP                                                      ->3
         35    >   FE_FREE                                                  $5
   28    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.0.0


preferences:
162.63 ms | 1400 KiB | 15 Q