3v4l.org

run code in 500+ PHP versions simultaneously
<?php $x = array(0 => 1, 2 => 3, 4 => 5, 6 => 7, 8 => 9); foreach ($x as $key => $value) { echo "first loop (foreach):" . $key . "=>" . $value . "\n"; if ($key == 4) { break; } } foreach ($x as $key => $value) { echo "second loop (foreach):" . $key . "=>" . $value . "\n"; } reset($x); while (list($key, $value) = each($x)) { echo "first loop (each):" . $key . "=>" . $value . "\n"; if ($key == 4) { break; } } while (list($key, $value) = each($x)) { echo "second loop (each):" . $key . "=>" . $value . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 13
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 28
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 45
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 45
Branch analysis from position: 58
Branch analysis from position: 45
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 36
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 36
Branch analysis from position: 23
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
Branch analysis from position: 13
filename:       /in/DZBS0
function name:  (null)
number of ops:  59
compiled vars:  !0 = $x, !1 = $value, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    5     1      > FE_RESET_R                                           $4      !0, ->13
          2    > > FE_FETCH_R                                           ~5      $4, !1, ->13
          3    >   ASSIGN                                                       !2, ~5
    6     4        CONCAT                                               ~7      'first+loop+%28foreach%29%3A', !2
          5        CONCAT                                               ~8      ~7, '%3D%3E'
          6        CONCAT                                               ~9      ~8, !1
          7        CONCAT                                               ~10     ~9, '%0A'
          8        ECHO                                                         ~10
    7     9        IS_EQUAL                                                     !2, 4
         10      > JMPZ                                                         ~11, ->12
    8    11    > > JMP                                                          ->13
    5    12    > > JMP                                                          ->2
         13    >   FE_FREE                                                      $4
   11    14      > FE_RESET_R                                           $12     !0, ->23
         15    > > FE_FETCH_R                                           ~13     $12, !1, ->23
         16    >   ASSIGN                                                       !2, ~13
   12    17        CONCAT                                               ~15     'second+loop+%28foreach%29%3A', !2
         18        CONCAT                                               ~16     ~15, '%3D%3E'
         19        CONCAT                                               ~17     ~16, !1
         20        CONCAT                                               ~18     ~17, '%0A'
         21        ECHO                                                         ~18
   11    22      > JMP                                                          ->15
         23    >   FE_FREE                                                      $12
   15    24        INIT_FCALL                                                   'reset'
         25        SEND_REF                                                     !0
         26        DO_ICALL                                                     
   16    27      > JMP                                                          ->36
   17    28    >   CONCAT                                               ~20     'first+loop+%28each%29%3A', !2
         29        CONCAT                                               ~21     ~20, '%3D%3E'
         30        CONCAT                                               ~22     ~21, !1
         31        CONCAT                                               ~23     ~22, '%0A'
         32        ECHO                                                         ~23
   18    33        IS_EQUAL                                                     !2, 4
         34      > JMPZ                                                         ~24, ->36
   19    35    > > JMP                                                          ->44
   16    36    >   INIT_FCALL_BY_NAME                                           'each'
         37        SEND_VAR_EX                                                  !0
         38        DO_FCALL                                          0  $25     
         39        FETCH_LIST_R                                         $26     $25, 0
         40        ASSIGN                                                       !2, $26
         41        FETCH_LIST_R                                         $28     $25, 1
         42        ASSIGN                                                       !1, $28
         43      > JMPNZ                                                        $25, ->28
   22    44    > > JMP                                                          ->50
   23    45    >   CONCAT                                               ~30     'second+loop+%28each%29%3A', !2
         46        CONCAT                                               ~31     ~30, '%3D%3E'
         47        CONCAT                                               ~32     ~31, !1
         48        CONCAT                                               ~33     ~32, '%0A'
         49        ECHO                                                         ~33
   22    50    >   INIT_FCALL_BY_NAME                                           'each'
         51        SEND_VAR_EX                                                  !0
         52        DO_FCALL                                          0  $34     
         53        FETCH_LIST_R                                         $35     $34, 0
         54        ASSIGN                                                       !2, $35
         55        FETCH_LIST_R                                         $37     $34, 1
         56        ASSIGN                                                       !1, $37
         57      > JMPNZ                                                        $34, ->45
   24    58    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.98 ms | 3182 KiB | 14 Q