3v4l.org

run code in 300+ PHP versions simultaneously
<?php $deep = ['a' => ['b' => ['c' => 5]]]; function set(array $array, array $keys, $value) { while ($key = array_pop($keys)) { $value = [$key => $value]; } return array_replace_recursive($array, $value); } function get(array $array, array $keys, $default = null) { while ($key = array_shift($keys)) { if (!isset($array[$key])) { return $default; } $array = $array[$key]; } return $array; } $test = set($deep, ['a', 'b', 'c'], 15); $value = get($test, ['a', 'b', 'c'], 'spaghetti'); var_dump($deep); var_dump($test); var_dump($value);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kdQZF
function name:  (null)
number of ops:  23
compiled vars:  !0 = $deep, !1 = $test, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   23     1        INIT_FCALL                                               'set'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <array>
          4        SEND_VAL                                                 15
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
   25     7        INIT_FCALL                                               'get'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 <array>
         10        SEND_VAL                                                 'spaghetti'
         11        DO_FCALL                                      0  $6      
         12        ASSIGN                                                   !2, $6
   28    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
   29    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                                 
   30    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
Branch analysis from position: 4
filename:       /in/kdQZF
function name:  set
number of ops:  17
compiled vars:  !0 = $array, !1 = $keys, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3      > JMP                                                      ->6
    8     4    >   INIT_ARRAY                                       ~4      !2, !3
          5        ASSIGN                                                   !2, ~4
    7     6    >   INIT_FCALL                                               'array_pop'
          7        SEND_REF                                                 !1
          8        DO_ICALL                                         $6      
          9        ASSIGN                                           ~7      !3, $6
         10      > JMPNZ                                                    ~7, ->4
   10    11    >   INIT_FCALL                                               'array_replace_recursive'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $8      
         15      > RETURN                                                   $8
   11    16*     > RETURN                                                   null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 4
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 4
Branch analysis from position: 15
Branch analysis from position: 4
filename:       /in/kdQZF
function name:  get
number of ops:  17
compiled vars:  !0 = $array, !1 = $keys, !2 = $default, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   13     3      > JMP                                                      ->10
   14     4    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !0, !3
          5        BOOL_NOT                                         ~5      ~4
          6      > JMPZ                                                     ~5, ->8
   15     7    > > RETURN                                                   !2
   17     8    >   FETCH_DIM_R                                      ~6      !0, !3
          9        ASSIGN                                                   !0, ~6
   13    10    >   INIT_FCALL                                               'array_shift'
         11        SEND_REF                                                 !1
         12        DO_ICALL                                         $8      
         13        ASSIGN                                           ~9      !3, $8
         14      > JMPNZ                                                    ~9, ->4
   19    15    > > RETURN                                                   !0
   20    16*     > RETURN                                                   null

End of function get

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
282.4 ms | 1403 KiB | 24 Q