3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array(1, 2, 3, 4, 5); foreach($a as $n) { echo "$n"; if ($n == 4) { $a = array_merge($a, array(6, 7)); } } $a = array(1, 2, 3, 4, 5); foreach($a as $n) { echo "$n"; if ($n == 4) { $a[] = 6; $a[] = 7; } } $a = array(1, 2, 3, 4, 5); foreach($a as $n) { echo "$n"; if ($n == 4) { array_push($a, 6); array_push($a, 7); } } $a = array(1, 2, 3, 4, 5); foreach($a as $n) { echo "$n"; if ($n == 4) { array_push($a, 6, 7); } } $a = array(1, 2, 3, 4, 5); foreach($a as $n) { echo "$n"; if ($n == 4) { array_push($a, array(6, 7)); } }
based on 87AV3
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 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 25
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 43
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 43
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 42
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 42
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 57
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 57
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 56
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 56
Branch analysis from position: 57
2 jumps found. (Code = 77) Position 1 = 60, Position 2 = 70
Branch analysis from position: 60
2 jumps found. (Code = 78) Position 1 = 61, Position 2 = 70
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 69
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
Branch analysis from position: 69
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
Branch analysis from position: 57
Branch analysis from position: 43
Branch analysis from position: 26
Branch analysis from position: 13
filename:       /in/KCqTI
function name:  (null)
number of ops:  72
compiled vars:  !0 = $a, !1 = $n
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ASSIGN                                                   !0, <array>
   3     1      > FE_RESET_R                                       $3      !0, ->13
         2    > > FE_FETCH_R                                               $3, !1, ->13
   4     3    >   CAST                                          6  ~4      !1
         4        ECHO                                                     ~4
   5     5        IS_EQUAL                                         ~5      !1, 4
         6      > JMPZ                                                     ~5, ->12
   6     7    >   INIT_FCALL                                               'array_merge'
         8        SEND_VAR                                                 !0
         9        SEND_VAL                                                 <array>
        10        DO_ICALL                                         $6      
        11        ASSIGN                                                   !0, $6
        12    > > JMP                                                      ->2
        13    >   FE_FREE                                                  $3
  11    14        ASSIGN                                                   !0, <array>
  12    15      > FE_RESET_R                                       $9      !0, ->26
        16    > > FE_FETCH_R                                               $9, !1, ->26
  13    17    >   CAST                                          6  ~10     !1
        18        ECHO                                                     ~10
  14    19        IS_EQUAL                                         ~11     !1, 4
        20      > JMPZ                                                     ~11, ->25
  15    21    >   ASSIGN_DIM                                               !0
        22        OP_DATA                                                  6
  16    23        ASSIGN_DIM                                               !0
        24        OP_DATA                                                  7
        25    > > JMP                                                      ->16
        26    >   FE_FREE                                                  $9
  20    27        ASSIGN                                                   !0, <array>
  21    28      > FE_RESET_R                                       $15     !0, ->43
        29    > > FE_FETCH_R                                               $15, !1, ->43
  22    30    >   CAST                                          6  ~16     !1
        31        ECHO                                                     ~16
  23    32        IS_EQUAL                                         ~17     !1, 4
        33      > JMPZ                                                     ~17, ->42
  24    34    >   INIT_FCALL                                               'array_push'
        35        SEND_REF                                                 !0
        36        SEND_VAL                                                 6
        37        DO_ICALL                                                 
  25    38        INIT_FCALL                                               'array_push'
        39        SEND_REF                                                 !0
        40        SEND_VAL                                                 7
        41        DO_ICALL                                                 
        42    > > JMP                                                      ->29
        43    >   FE_FREE                                                  $15
  29    44        ASSIGN                                                   !0, <array>
  30    45      > FE_RESET_R                                       $21     !0, ->57
        46    > > FE_FETCH_R                                               $21, !1, ->57
  31    47    >   CAST                                          6  ~22     !1
        48        ECHO                                                     ~22
  32    49        IS_EQUAL                                         ~23     !1, 4
        50      > JMPZ                                                     ~23, ->56
  33    51    >   INIT_FCALL                                               'array_push'
        52        SEND_REF                                                 !0
        53        SEND_VAL                                                 6
        54        SEND_VAL                                                 7
        55        DO_ICALL                                                 
        56    > > JMP                                                      ->46
        57    >   FE_FREE                                                  $21
  37    58        ASSIGN                                                   !0, <array>
  38    59      > FE_RESET_R                                       $26     !0, ->70
        60    > > FE_FETCH_R                                               $26, !1, ->70
  39    61    >   CAST                                          6  ~27     !1
        62        ECHO                                                     ~27
  40    63        IS_EQUAL                                         ~28     !1, 4
        64      > JMPZ                                                     ~28, ->69
  41    65    >   INIT_FCALL                                               'array_push'
        66        SEND_REF                                                 !0
        67        SEND_VAL                                                 <array>
        68        DO_ICALL                                                 
        69    > > JMP                                                      ->60
        70    >   FE_FREE                                                  $26
  43    71      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.3.0