3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'Name/First' => 'John', 'Name/Last' => 'Doe', 'Age' => 20, 'Address/Postal/City' => 'New York', 'Address/Postal/Zip' => 10003, 'Address/Billing/City' => 'Los Angeles', 'Phone' => 123456789, 'Foo/Bar/Foo2/Bar2' => 'test', ]; $newarray = []; foreach($array as $path => $value) { $keys = array_filter(explode('/', $path)); $ref = &$newarray; foreach($keys as $level => $key) { $ref = &$ref[$key]; } $ref = $value; } print_r($newarray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/4Wfua
function name:  (null)
number of ops:  28
compiled vars:  !0 = $array, !1 = $newarray, !2 = $value, !3 = $path, !4 = $keys, !5 = $ref, !6 = $key, !7 = $level
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   16     2      > FE_RESET_R                                       $10     !0, ->23
          3    > > FE_FETCH_R                                       ~11     $10, !2, ->23
          4    >   ASSIGN                                                   !3, ~11
   17     5        INIT_FCALL                                               'array_filter'
          6        INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '%2F'
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                         $13     
         10        SEND_VAR                                                 $13
         11        DO_ICALL                                         $14     
         12        ASSIGN                                                   !4, $14
   18    13        ASSIGN_REF                                               !5, !1
   19    14      > FE_RESET_R                                       $17     !4, ->20
         15    > > FE_FETCH_R                                       ~18     $17, !6, ->20
         16    >   ASSIGN                                                   !7, ~18
   20    17        FETCH_DIM_W                                      $20     !5, !6
         18        ASSIGN_REF                                               !5, $20
   19    19      > JMP                                                      ->15
         20    >   FE_FREE                                                  $17
   22    21        ASSIGN                                                   !5, !2
   16    22      > JMP                                                      ->3
         23    >   FE_FREE                                                  $10
   25    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.37 ms | 1005 KiB | 16 Q