3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [1,2]; foreach($array as $a) { if ($a == 1) { $array[] = 3; } echo $a . "\n"; } echo "-----\n"; $array = [1,2]; foreach($array as &$a) { if ($a == 1) { $array[] = 3; $array[] = 4; } echo $a . "\n"; } $a = 10; echo "----------\n"; var_dump($array); reset($array); foreach($array as $a) { echo $a . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
Branch analysis from position: 10
2 jumps found. (Code = 125) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 126) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 21
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 24
Branch analysis from position: 10
filename:       /in/87rgQ
function name:  (null)
number of ops:  40
compiled vars:  !0 = $array, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                               $3, !1, ->10
    6     3    >   IS_EQUAL                                                 !1, 1
          4      > JMPZ                                                     ~4, ->7
    7     5    >   ASSIGN_DIM                                               !0
          6        OP_DATA                                                  3
    9     7    >   CONCAT                                           ~6      !1, '%0A'
          8        ECHO                                                     ~6
    5     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   12    11        ECHO                                                     '-----%0A'
   15    12        ASSIGN                                                   !0, <array>
   17    13      > FE_RESET_RW                                      $8      !0, ->24
         14    > > FE_FETCH_RW                                              $8, !1, ->24
   18    15    >   IS_EQUAL                                                 !1, 1
         16      > JMPZ                                                     ~9, ->21
   19    17    >   ASSIGN_DIM                                               !0
         18        OP_DATA                                                  3
   20    19        ASSIGN_DIM                                               !0
         20        OP_DATA                                                  4
   22    21    >   CONCAT                                           ~12     !1, '%0A'
         22        ECHO                                                     ~12
   17    23      > JMP                                                      ->14
         24    >   FE_FREE                                                  $8
   25    25        ASSIGN                                                   !1, 10
   27    26        ECHO                                                     '----------%0A'
   28    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                                 
   29    30        INIT_FCALL                                               'reset'
         31        SEND_REF                                                 !0
         32        DO_ICALL                                                 
   30    33      > FE_RESET_R                                       $16     !0, ->38
         34    > > FE_FETCH_R                                               $16, !1, ->38
   31    35    >   CONCAT                                           ~17     !1, '%0A'
         36        ECHO                                                     ~17
   30    37      > JMP                                                      ->34
         38    >   FE_FREE                                                  $16
   32    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.74 ms | 1400 KiB | 17 Q