3v4l.org

run code in 300+ PHP versions simultaneously
<?php // works correctly $hash = (object) [ 'a' => 1, 'b' => 2, 'c' => 3, ]; foreach ($hash as $key => $value) { var_dump($key); unset($hash->$key); } echo "\n"; // BUG: skips item 'b' $hash = (object) [ 'a' => 1, 'b' => 2, 'c' => 3, ]; $it = new ArrayIterator($hash); foreach ($it as $key => $value) { var_dump($key); unset($hash->$key); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 10
filename:       /in/2A1pf
function name:  (null)
number of ops:  28
compiled vars:  !0 = $hash, !1 = $value, !2 = $key, !3 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   CAST                                          8  ~4      <array>
    4     1        ASSIGN                                                   !0, ~4
   10     2      > FE_RESET_R                                       $6      !0, ->10
          3    > > FE_FETCH_R                                       ~7      $6, !1, ->10
          4    >   ASSIGN                                                   !2, ~7
   11     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                                 
   12     8        UNSET_OBJ                                                !0, !2
   10     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $6
   15    11        ECHO                                                     '%0A'
   20    12        CAST                                          8  ~10     <array>
   19    13        ASSIGN                                                   !0, ~10
   25    14        NEW                                              $12     'ArrayIterator'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !3, $12
   27    18      > FE_RESET_R                                       $15     !3, ->26
         19    > > FE_FETCH_R                                       ~16     $15, !1, ->26
         20    >   ASSIGN                                                   !2, ~16
   28    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
   29    24        UNSET_OBJ                                                !0, !2
   27    25      > JMP                                                      ->19
         26    >   FE_FREE                                                  $15
   30    27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.7 ms | 1396 KiB | 15 Q