3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [1, 2, 3, 4, 6, 7, 9, 10, 11]; $result = []; $index = 0; foreach ($array as $i => $value) { $result[$index += ($i && $value !== $array[$i - 1] + 1)][] = $value; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/S8NBp
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array, !1 = $result, !2 = $index, !3 = $value, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, 0
    7     3      > FE_RESET_R                                       $8      !0, ->17
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->17
          5    >   ASSIGN                                                   !4, ~9
    8     6      > JMPZ_EX                                          ~11     !4, ->12
          7    >   SUB                                              ~12     !4, 1
          8        FETCH_DIM_R                                      ~13     !0, ~12
          9        ADD                                              ~14     ~13, 1
         10        IS_NOT_IDENTICAL                                 ~15     !3, ~14
         11        BOOL                                             ~11     ~15
         12    >   ASSIGN_OP                                     1  ~16     !2, ~11
         13        FETCH_DIM_W                                      $17     !1, ~16
         14        ASSIGN_DIM                                               $17
         15        OP_DATA                                                  !3
    7    16      > JMP                                                      ->4
         17    >   FE_FREE                                                  $8
   10    18        INIT_FCALL                                               'var_export'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.2 ms | 997 KiB | 14 Q