3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = [ '2021-07-05', '2021-07-06', '2021-07-07', '2021-07-08', '2021-07-09', '2021-07-10', '2021-07-11', '2021-07-12', '2021-07-13', '2021-07-14', '2021-07-15', '2021-07-16', '2021-07-17', '2021-07-18', '2021-07-19', '2021-07-20', '2021-07-21', '2021-07-22', ]; $from = $dates[0]; $to = $from; $result = []; foreach($dates as $date) { if (strtotime($from) + 60 * 60 * 24 * 6 < strtotime($date)) { $result[] = ['from' => $from, 'to' => $to]; $from = $to; } $to = $date; } $result[] = ['from' => $from, 'to' => $to]; print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 23
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 21
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/ueF2O
function name:  (null)
number of ops:  32
compiled vars:  !0 = $dates, !1 = $from, !2 = $to, !3 = $result, !4 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        FETCH_DIM_R                                      ~6      !0, 0
          2        ASSIGN                                                   !1, ~6
   25     3        ASSIGN                                                   !2, !1
   26     4        ASSIGN                                                   !3, <array>
   28     5      > FE_RESET_R                                       $10     !0, ->23
          6    > > FE_FETCH_R                                               $10, !4, ->23
   29     7    >   INIT_FCALL                                               'strtotime'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $11     
         10        ADD                                              ~12     $11, 518400
         11        INIT_FCALL                                               'strtotime'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $13     
         14        IS_SMALLER                                               ~12, $13
         15      > JMPZ                                                     ~14, ->21
   30    16    >   INIT_ARRAY                                       ~16     !1, 'from'
         17        ADD_ARRAY_ELEMENT                                ~16     !2, 'to'
         18        ASSIGN_DIM                                               !3
         19        OP_DATA                                                  ~16
   31    20        ASSIGN                                                   !1, !2
   33    21    >   ASSIGN                                                   !2, !4
   28    22      > JMP                                                      ->6
         23    >   FE_FREE                                                  $10
   35    24        INIT_ARRAY                                       ~20     !1, 'from'
         25        ADD_ARRAY_ELEMENT                                ~20     !2, 'to'
         26        ASSIGN_DIM                                               !3
         27        OP_DATA                                                  ~20
   37    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.16 ms | 1396 KiB | 17 Q