3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = ['a_b_c' => 123]; function assignArrayByPath(&$arr, $path, $value, $separator='.') { $keys = explode($separator, $path); foreach ($keys as $key) { $arr = &$arr[$key]; } $arr = $value; } $result = []; assignArrayByPath($result, key($array), reset($array), '_'); var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lVZjF
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array, !1 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   15     1        ASSIGN                                                       !1, <array>
   16     2        INIT_FCALL                                                   'assignarraybypath'
          3        SEND_REF                                                     !1
          4        INIT_FCALL                                                   'key'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $4      
          7        SEND_VAR                                                     $4
          8        INIT_FCALL                                                   'reset'
          9        SEND_REF                                                     !0
         10        DO_ICALL                                             $5      
         11        SEND_VAR                                                     $5
         12        SEND_VAL                                                     '_'
         13        DO_FCALL                                          0          
   17    14        INIT_FCALL                                                   'var_export'
         15        SEND_VAR                                                     !1
         16        DO_ICALL                                                     
         17      > RETURN                                                       1

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

End of function assignarraybypath

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.23 ms | 1876 KiB | 18 Q