3v4l.org

run code in 300+ PHP versions simultaneously
<?php function assignArrayByPath(&$result, $path, $value) { foreach (explode('_', $path) as $key) { $result = &$result[$key]; } $result = $value; } $array = [ 'max_size_video' => 50000, 'max_size_photo' => 8000, 'token_expire' => 100, 'dns' => 'mydns.fr', ]; $result = []; foreach ($array as $key => $value) { assignArrayByPath($result, $key, $value); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/EnIPt
function name:  (null)
number of ops:  16
compiled vars:  !0 = $array, !1 = $result, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, <array>
   18     2      > FE_RESET_R                                       $6      !0, ->11
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->11
          4    >   ASSIGN                                                   !3, ~7
   19     5        INIT_FCALL                                               'assignarraybypath'
          6        SEND_REF                                                 !1
          7        SEND_VAR                                                 !3
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0          
   18    10      > JMP                                                      ->3
         11    >   FE_FREE                                                  $6
   21    12        INIT_FCALL                                               'var_export'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function assignarraybypath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/EnIPt
function name:  assignArrayByPath
number of ops:  15
compiled vars:  !0 = $result, !1 = $path, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '_'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $4      
          7      > FE_RESET_R                                       $5      $4, ->12
          8    > > FE_FETCH_R                                               $5, !3, ->12
    5     9    >   FETCH_DIM_W                                      $6      !0, !3
         10        ASSIGN_REF                                               !0, $6
    4    11      > JMP                                                      ->8
         12    >   FE_FREE                                                  $5
    7    13        ASSIGN                                                   !0, !2
    8    14      > RETURN                                                   null

End of function assignarraybypath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
206.51 ms | 1403 KiB | 18 Q