3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = [ new DateTime('2017-04-22 12:45:49.000000'), new DateTime('2017-04-21 12:45:49.000000'), new DateTime('2015-04-18 12:45:49.000000'), ]; sort($dates); $i = 0; $previous = null; foreach ($dates as $date) { if ($previous && $date->diff($previous)->days > 1) { $i++; } $groups[$i][] = $date; $previous = $date; } var_dump($groups);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 34
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 34
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
Branch analysis from position: 27
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/1hh4H
function name:  (null)
number of ops:  39
compiled vars:  !0 = $dates, !1 = $i, !2 = $previous, !3 = $date, !4 = $groups
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   NEW                                              $5      'DateTime'
          1        SEND_VAL_EX                                              '2017-04-22+12%3A45%3A49.000000'
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~7      $5
    5     4        NEW                                              $8      'DateTime'
          5        SEND_VAL_EX                                              '2017-04-21+12%3A45%3A49.000000'
          6        DO_FCALL                                      0          
          7        ADD_ARRAY_ELEMENT                                ~7      $8
    6     8        NEW                                              $10     'DateTime'
          9        SEND_VAL_EX                                              '2015-04-18+12%3A45%3A49.000000'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~7      $10
    3    12        ASSIGN                                                   !0, ~7
   10    13        INIT_FCALL                                               'sort'
         14        SEND_REF                                                 !0
         15        DO_ICALL                                                 
   12    16        ASSIGN                                                   !1, 0
   13    17        ASSIGN                                                   !2, null
   15    18      > FE_RESET_R                                       $16     !0, ->34
         19    > > FE_FETCH_R                                               $16, !3, ->34
   16    20    > > JMPZ_EX                                          ~17     !2, ->27
         21    >   INIT_METHOD_CALL                                         !3, 'diff'
         22        SEND_VAR_EX                                              !2
         23        DO_FCALL                                      0  $18     
         24        FETCH_OBJ_R                                      ~19     $18, 'days'
         25        IS_SMALLER                                       ~20     1, ~19
         26        BOOL                                             ~17     ~20
         27    > > JMPZ                                                     ~17, ->29
   17    28    >   PRE_INC                                                  !1
   19    29    >   FETCH_DIM_W                                      $22     !4, !1
         30        ASSIGN_DIM                                               $22
         31        OP_DATA                                                  !3
   20    32        ASSIGN                                                   !2, !3
   15    33      > JMP                                                      ->19
         34    >   FE_FREE                                                  $16
   23    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
213.42 ms | 1400 KiB | 17 Q