3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ //"STOPSALES", "2023-03-10", "2023-03-11", "2023-03-12", "2023-03-13", "2023-03-14", "2023-03-15", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "STOPSALES", "2023-03-27", "2023-03-28", "2023-03-29", "2023-03-30", "2023-03-31", "2023-04-01", "2023-04-02", "2023-04-03", ]; $result = []; $k = 0; foreach ($array as $i => $v) { if ($v !== 'STOPSALES') { if (($array[$i - 1] ?? null) === 'STOPSALES') { ++$k; } $result[$k][] = $v; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/NEmc1
function name:  (null)
number of ops:  24
compiled vars:  !0 = $array, !1 = $result, !2 = $k, !3 = $v, !4 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   32     1        ASSIGN                                                       !1, <array>
   33     2        ASSIGN                                                       !2, 0
   34     3      > FE_RESET_R                                           $8      !0, ->19
          4    > > FE_FETCH_R                                           ~9      $8, !3, ->19
          5    >   ASSIGN                                                       !4, ~9
   35     6        IS_NOT_IDENTICAL                                             !3, 'STOPSALES'
          7      > JMPZ                                                         ~11, ->18
   36     8    >   SUB                                                  ~12     !4, 1
          9        FETCH_DIM_IS                                         ~13     !0, ~12
         10        COALESCE                                             ~14     ~13
         11        QM_ASSIGN                                            ~14     null
         12        IS_IDENTICAL                                                 ~14, 'STOPSALES'
         13      > JMPZ                                                         ~15, ->15
   37    14    >   PRE_INC                                                      !2
   39    15    >   FETCH_DIM_W                                          $17     !1, !2
         16        ASSIGN_DIM                                                   $17
         17        OP_DATA                                                      !3
   34    18    > > JMP                                                          ->4
         19    >   FE_FREE                                                      $8
   42    20        INIT_FCALL                                                   'var_export'
         21        SEND_VAR                                                     !1
         22        DO_ICALL                                                     
         23      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
147.46 ms | 1794 KiB | 14 Q