3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [1, 2, 3, 4, 5, 6]; for ($i = 0; $i < count($arr); $i++) { unset($arr[$i - 1]); var_dump($arr[$i]); } echo "===", PHP_EOL; $arr = [1, 2, 3, 4, 5, 6]; foreach ($arr as $i => $v) { unset($arr[$i - 1]); var_dump($arr[$i]); }
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 = 13, Position 2 = 3
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
Branch analysis from position: 3
filename:       /in/bQGE3
function name:  (null)
number of ops:  28
compiled vars:  !0 = $arr, !1 = $i, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->10
    5     3    >   SUB                                              ~5      !1, 1
          4        UNSET_DIM                                                !0, ~5
    6     5        INIT_FCALL                                               'var_dump'
          6        FETCH_DIM_R                                      ~6      !0, !1
          7        SEND_VAL                                                 ~6
          8        DO_ICALL                                                 
    4     9        PRE_INC                                                  !1
         10    >   COUNT                                            ~9      !0
         11        IS_SMALLER                                               !1, ~9
         12      > JMPNZ                                                    ~10, ->3
    8    13    >   ECHO                                                     '%3D%3D%3D'
         14        ECHO                                                     '%0A'
    9    15        ASSIGN                                                   !0, <array>
   11    16      > FE_RESET_R                                       $12     !0, ->26
         17    > > FE_FETCH_R                                       ~13     $12, !2, ->26
         18    >   ASSIGN                                                   !1, ~13
   12    19        SUB                                              ~15     !1, 1
         20        UNSET_DIM                                                !0, ~15
   13    21        INIT_FCALL                                               'var_dump'
         22        FETCH_DIM_R                                      ~16     !0, !1
         23        SEND_VAL                                                 ~16
         24        DO_ICALL                                                 
   11    25      > JMP                                                      ->17
         26    >   FE_FREE                                                  $12
   14    27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
198.76 ms | 1003 KiB | 14 Q