3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['hello' => ['deep' => ['deep1' => array('treasure')]]]; $keys = ["hello", "deep", "deep1", 0]; function remove_recursive(&$array, $keys, $level = 0) { if ($level >= count($keys)) { return $array; } if (isset($array[$keys[$level]]) && $level == count($keys) - 1) { unset($array[$keys[$level]]); } elseif (isset($array[$keys[$level]])) { $array[$keys[$level]] = remove_recursive($array[$keys[$level]], $keys, $level + 1); } return $array; } var_dump(remove_recursive($array, $keys));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i75oS
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array, !1 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
   19     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'remove_recursive'
          4        SEND_REF                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function remove_recursive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 33
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 14
filename:       /in/i75oS
function name:  remove_recursive
number of ops:  35
compiled vars:  !0 = $array, !1 = $keys, !2 = $level
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
    7     3        COUNT                                            ~3      !1
          4        IS_SMALLER_OR_EQUAL                                      ~3, !2
          5      > JMPZ                                                     ~4, ->7
    8     6    > > RETURN                                                   !0
   10     7    >   FETCH_DIM_R                                      ~5      !1, !2
          8        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, ~5
          9      > JMPZ_EX                                          ~6      ~6, ->14
         10    >   COUNT                                            ~7      !1
         11        SUB                                              ~8      ~7, 1
         12        IS_EQUAL                                         ~9      !2, ~8
         13        BOOL                                             ~6      ~9
         14    > > JMPZ                                                     ~6, ->18
   11    15    >   FETCH_DIM_R                                      ~10     !1, !2
         16        UNSET_DIM                                                !0, ~10
         17      > JMP                                                      ->33
   12    18    >   FETCH_DIM_R                                      ~11     !1, !2
         19        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~11
         20      > JMPZ                                                     ~12, ->33
   13    21    >   FETCH_DIM_R                                      ~13     !1, !2
         22        INIT_FCALL_BY_NAME                                       'remove_recursive'
         23        CHECK_FUNC_ARG                                           
         24        FETCH_DIM_R                                      ~15     !1, !2
         25        FETCH_DIM_FUNC_ARG                               $16     !0, ~15
         26        SEND_FUNC_ARG                                            $16
         27        SEND_VAR_EX                                              !1
         28        ADD                                              ~17     !2, 1
         29        SEND_VAL_EX                                              ~17
         30        DO_FCALL                                      0  $18     
         31        ASSIGN_DIM                                               !0, ~13
         32        OP_DATA                                                  $18
   16    33    > > RETURN                                                   !0
   17    34*     > RETURN                                                   null

End of function remove_recursive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
314.73 ms | 1403 KiB | 17 Q