3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [0, 1, 2]; $ref =& $array; // Necessary to trigger the old behavior $i = 0; foreach ($array as $k => &$val) { $i++; echo $val . ' '; if($i < 5 && !isset($array[$i])) $array[$i] = $val+1; if($i == 2) array_unshift($array, 'X'); } echo PHP_EOL . json_encode($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 126) Position 1 = 5, Position 2 = 25
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
Branch analysis from position: 18
Branch analysis from position: 14
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/tAW3C
function name:  (null)
number of ops:  32
compiled vars:  !0 = $array, !1 = $ref, !2 = $i, !3 = $val, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN_REF                                               !1, !0
    5     2        ASSIGN                                                   !2, 0
    6     3      > FE_RESET_RW                                      $8      !0, ->25
          4    > > FE_FETCH_RW                                      ~9      $8, !3, ->25
          5    >   ASSIGN                                                   !4, ~9
    7     6        PRE_INC                                                  !2
    8     7        CONCAT                                           ~12     !3, '+'
          8        ECHO                                                     ~12
    9     9        IS_SMALLER                                       ~13     !2, 5
         10      > JMPZ_EX                                          ~13     ~13, ->14
         11    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !0, !2
         12        BOOL_NOT                                         ~15     ~14
         13        BOOL                                             ~13     ~15
         14    > > JMPZ                                                     ~13, ->18
         15    >   ADD                                              ~17     !3, 1
         16        ASSIGN_DIM                                               !0, !2
         17        OP_DATA                                                  ~17
   10    18    >   IS_EQUAL                                                 !2, 2
         19      > JMPZ                                                     ~18, ->24
         20    >   INIT_FCALL                                               'array_unshift'
         21        SEND_REF                                                 !0
         22        SEND_VAL                                                 'X'
         23        DO_ICALL                                                 
    6    24    > > JMP                                                      ->4
         25    >   FE_FREE                                                  $8
   12    26        INIT_FCALL                                               'json_encode'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $20     
         29        CONCAT                                           ~21     '%0A', $20
         30        ECHO                                                     ~21
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.93 ms | 1400 KiB | 17 Q