3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [1, 2, 3, 5, 4, 7, 6, 8, 9]; $batches = generateBatches($input); function generateBatches($input) { $batches = []; $batchNumber = 0; $prev = 0; foreach ($input as $i) { if ($i > 1 && $i - $prev < 1) { $batchNumber++; } $batches[$batchNumber][] = $i; $prev = $i; } return $batches; } print_r($batches);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f0DE2
function name:  (null)
number of ops:  9
compiled vars:  !0 = $input, !1 = $batches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL_BY_NAME                                       'generateBatches'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   29     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function generatebatches:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
Branch analysis from position: 11
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/f0DE2
function name:  generateBatches
number of ops:  21
compiled vars:  !0 = $input, !1 = $batches, !2 = $batchNumber, !3 = $prev, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN                                                   !1, <array>
   10     2        ASSIGN                                                   !2, 0
   11     3        ASSIGN                                                   !3, 0
   13     4      > FE_RESET_R                                       $8      !0, ->18
          5    > > FE_FETCH_R                                               $8, !4, ->18
   17     6    >   IS_SMALLER                                       ~9      1, !4
          7      > JMPZ_EX                                          ~9      ~9, ->11
          8    >   SUB                                              ~10     !4, !3
          9        IS_SMALLER                                       ~11     ~10, 1
         10        BOOL                                             ~9      ~11
         11    > > JMPZ                                                     ~9, ->13
   18    12    >   PRE_INC                                                  !2
   21    13    >   FETCH_DIM_W                                      $13     !1, !2
         14        ASSIGN_DIM                                               $13
         15        OP_DATA                                                  !4
   23    16        ASSIGN                                                   !3, !4
   13    17      > JMP                                                      ->5
         18    >   FE_FREE                                                  $8
   26    19      > RETURN                                                   !1
   27    20*     > RETURN                                                   null

End of function generatebatches

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.08 ms | 1011 KiB | 14 Q