3v4l.org

run code in 300+ PHP versions simultaneously
<?php function buildArray($array) { $new = array(); $current = &$new; foreach($array as $key => $value) { $current[$value] = array(); $current = &$current[$value]; } return $new; } $test = array ( 0 => 'Tree', 1 => 'Trunk', 2 => 'Branch', 3 => 'Limb', 4 => 'Apple', 5 => 'Seed' ); print_r(buildArray($test));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cmsqY
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'buildarray'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function buildarray:
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
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/cmsqY
function name:  buildArray
number of ops:  14
compiled vars:  !0 = $array, !1 = $new, !2 = $current, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN_REF                                               !2, !1
    7     3      > FE_RESET_R                                       $7      !0, ->11
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->11
          5    >   ASSIGN                                                   !4, ~8
    9     6        ASSIGN_DIM                                               !2, !3
          7        OP_DATA                                                  <array>
   10     8        FETCH_DIM_W                                      $11     !2, !3
          9        ASSIGN_REF                                               !2, $11
    7    10      > JMP                                                      ->4
         11    >   FE_FREE                                                  $7
   12    12      > RETURN                                                   !1
   13    13*     > RETURN                                                   null

End of function buildarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.57 ms | 1012 KiB | 15 Q