3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.75 ms | 1396 KiB | 17 Q