3v4l.org

run code in 300+ PHP versions simultaneously
<?php $seriesArray = array(1, 2, 3, 5, 7, 8, 11, 12, 15); $result = array(); $indx = 0; foreach($seriesArray as $key => $val){ $tmp = $seriesArray[$key]; $next = (isset($seriesArray[$key+1]))? $seriesArray[$key+1] : ''; if($next != ''){ if(!isset($result[$indx])) $result[$indx] = array(); if(($tmp+1) == $next ){ $result[$indx][] = $tmp; }else{ $result[$indx][] = $tmp; $indx++; } }else{ $result[$indx][] = $tmp; } } foreach($result as $key => $val){ echo "Series ".($key+1)." : ".implode(",",$result[$key])."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 40
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 40
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 36
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 24
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 36
Branch analysis from position: 19
Branch analysis from position: 36
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 56
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 56
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 40
filename:       /in/gFa40
function name:  (null)
number of ops:  58
compiled vars:  !0 = $seriesArray, !1 = $result, !2 = $indx, !3 = $val, !4 = $key, !5 = $tmp, !6 = $next
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    7     2        ASSIGN                                                   !2, 0
    8     3      > FE_RESET_R                                       $10     !0, ->40
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->40
          5    >   ASSIGN                                                   !4, ~11
    9     6        FETCH_DIM_R                                      ~13     !0, !4
          7        ASSIGN                                                   !5, ~13
   10     8        ADD                                              ~15     !4, 1
          9        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~15
         10      > JMPZ                                                     ~16, ->15
         11    >   ADD                                              ~17     !4, 1
         12        FETCH_DIM_R                                      ~18     !0, ~17
         13        QM_ASSIGN                                        ~19     ~18
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~19     ''
         16    >   ASSIGN                                                   !6, ~19
   11    17        IS_NOT_EQUAL                                             !6, ''
         18      > JMPZ                                                     ~21, ->36
   12    19    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~22     !1, !2
         20        BOOL_NOT                                         ~23     ~22
         21      > JMPZ                                                     ~23, ->24
         22    >   ASSIGN_DIM                                               !1, !2
         23        OP_DATA                                                  <array>
   13    24    >   ADD                                              ~25     !5, 1
         25        IS_EQUAL                                                 !6, ~25
         26      > JMPZ                                                     ~26, ->31
   14    27    >   FETCH_DIM_W                                      $27     !1, !2
         28        ASSIGN_DIM                                               $27
         29        OP_DATA                                                  !5
   13    30      > JMP                                                      ->35
   16    31    >   FETCH_DIM_W                                      $29     !1, !2
         32        ASSIGN_DIM                                               $29
         33        OP_DATA                                                  !5
   17    34        PRE_INC                                                  !2
   11    35    > > JMP                                                      ->39
   21    36    >   FETCH_DIM_W                                      $32     !1, !2
         37        ASSIGN_DIM                                               $32
         38        OP_DATA                                                  !5
    8    39    > > JMP                                                      ->4
         40    >   FE_FREE                                                  $10
   24    41      > FE_RESET_R                                       $34     !1, ->56
         42    > > FE_FETCH_R                                       ~35     $34, !3, ->56
         43    >   ASSIGN                                                   !4, ~35
   25    44        ADD                                              ~37     !4, 1
         45        CONCAT                                           ~38     'Series+', ~37
         46        CONCAT                                           ~39     ~38, '++%3A+'
         47        INIT_FCALL                                               'implode'
         48        SEND_VAL                                                 '%2C'
         49        FETCH_DIM_R                                      ~40     !1, !4
         50        SEND_VAL                                                 ~40
         51        DO_ICALL                                         $41     
         52        CONCAT                                           ~42     ~39, $41
         53        CONCAT                                           ~43     ~42, '%0A'
         54        ECHO                                                     ~43
   24    55      > JMP                                                      ->42
         56    >   FE_FREE                                                  $34
   26    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
283.34 ms | 1015 KiB | 14 Q