3v4l.org

run code in 300+ PHP versions simultaneously
<?php function forget(&$array, $keys) { $original =& $array; foreach ((array) $keys as $key) { $parts = explode('.', $key); while (count($parts) > 1) { $part = array_shift($parts); if (isset($array[$part]) && is_array($array[$part])) { $array =& $array[$part]; } } unset($array[array_shift($parts)]); // clean up after each pass $array =& $original; } } $a = ['a' => 0, 'b' => 'd']; forget($a, ['b']); print_r($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vpeVH
function name:  (null)
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN                                                   !0, <array>
   29     1        INIT_FCALL                                               'forget'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0          
   30     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function forget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 33
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 33
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 12
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 12
Branch analysis from position: 27
Branch analysis from position: 12
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/vpeVH
function name:  forget
number of ops:  35
compiled vars:  !0 = $array, !1 = $keys, !2 = $original, !3 = $key, !4 = $parts, !5 = $part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN_REF                                               !2, !0
    7     3        CAST                                          7  ~7      !1
          4      > FE_RESET_R                                       $8      ~7, ->33
          5    > > FE_FETCH_R                                               $8, !3, ->33
    9     6    >   INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '.'
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !4, $9
   11    11      > JMP                                                      ->24
   13    12    >   INIT_FCALL                                               'array_shift'
         13        SEND_REF                                                 !4
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !5, $11
   15    16        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !0, !5
         17      > JMPZ_EX                                          ~13     ~13, ->21
         18    >   FETCH_DIM_R                                      ~14     !0, !5
         19        TYPE_CHECK                                  128  ~15     ~14
         20        BOOL                                             ~13     ~15
         21    > > JMPZ                                                     ~13, ->24
   17    22    >   FETCH_DIM_W                                      $16     !0, !5
         23        ASSIGN_REF                                               !0, $16
   11    24    >   COUNT                                            ~18     !4
         25        IS_SMALLER                                               1, ~18
         26      > JMPNZ                                                    ~19, ->12
   21    27    >   INIT_FCALL                                               'array_shift'
         28        SEND_REF                                                 !4
         29        DO_ICALL                                         $20     
         30        UNSET_DIM                                                !0, $20
   24    31        ASSIGN_REF                                               !0, !2
    7    32      > JMP                                                      ->5
         33    >   FE_FREE                                                  $8
   26    34      > RETURN                                                   null

End of function forget

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
224.13 ms | 1403 KiB | 20 Q