3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startDate = '2017-03-31'; $endDate = '2017-05-14'; $fromDate = explode("-", $startDate); $toDate = explode("-", $endDate); $start = new DateTime($startDate); $end = new DateTime($endDate); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($start, $interval, $end); //print_r($interval); foreach ($period as $dt) { $date = $dt->format("Y-m-d"); print $date.'<br>'; $firstDate = $date."-15"; $secondDate = $date."-28"; if((strtotime($endDate) >= strtotime($firstDate)) && (strtotime($startDate) <= strtotime($firstDate))) $res[] = $firstDate; if((strtotime($endDate) >= strtotime($secondDate)) && (strtotime($startDate) <= strtotime($secondDate))) $res[] = $secondDate; } print_r($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 81
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 81
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 58
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
2 jumps found. (Code = 46) Position 1 = 69, Position 2 = 77
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 80
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 80
Branch analysis from position: 77
Branch analysis from position: 61
Branch analysis from position: 58
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
filename:       /in/EOSvQ
function name:  (null)
number of ops:  86
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $fromDate, !3 = $toDate, !4 = $start, !5 = $end, !6 = $interval, !7 = $period, !8 = $dt, !9 = $date, !10 = $firstDate, !11 = $secondDate, !12 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2017-03-31'
    4     1        ASSIGN                                                   !1, '2017-05-14'
    6     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '-'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $15     
          6        ASSIGN                                                   !2, $15
    7     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '-'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $17     
         11        ASSIGN                                                   !3, $17
    8    12        NEW                                              $19     'DateTime'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !4, $19
    9    16        NEW                                              $22     'DateTime'
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !5, $22
   10    20        INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
         21        SEND_VAL                                                 '1+month'
         22        DO_FCALL                                      0  $25     
         23        ASSIGN                                                   !6, $25
   11    24        NEW                                              $27     'DatePeriod'
         25        SEND_VAR_EX                                              !4
         26        SEND_VAR_EX                                              !6
         27        SEND_VAR_EX                                              !5
         28        DO_FCALL                                      0          
         29        ASSIGN                                                   !7, $27
   15    30      > FE_RESET_R                                       $30     !7, ->81
         31    > > FE_FETCH_R                                               $30, !8, ->81
   16    32    >   INIT_METHOD_CALL                                         !8, 'format'
         33        SEND_VAL_EX                                              'Y-m-d'
         34        DO_FCALL                                      0  $31     
         35        ASSIGN                                                   !9, $31
   17    36        CONCAT                                           ~33     !9, '%3Cbr%3E'
         37        ECHO                                                     ~33
   18    38        CONCAT                                           ~34     !9, '-15'
         39        ASSIGN                                                   !10, ~34
   19    40        CONCAT                                           ~36     !9, '-28'
         41        ASSIGN                                                   !11, ~36
   20    42        INIT_FCALL                                               'strtotime'
         43        SEND_VAR                                                 !1
         44        DO_ICALL                                         $38     
         45        INIT_FCALL                                               'strtotime'
         46        SEND_VAR                                                 !10
         47        DO_ICALL                                         $39     
         48        IS_SMALLER_OR_EQUAL                              ~40     $39, $38
         49      > JMPZ_EX                                          ~40     ~40, ->58
         50    >   INIT_FCALL                                               'strtotime'
         51        SEND_VAR                                                 !0
         52        DO_ICALL                                         $41     
         53        INIT_FCALL                                               'strtotime'
         54        SEND_VAR                                                 !10
         55        DO_ICALL                                         $42     
         56        IS_SMALLER_OR_EQUAL                              ~43     $41, $42
         57        BOOL                                             ~40     ~43
         58    > > JMPZ                                                     ~40, ->61
   21    59    >   ASSIGN_DIM                                               !12
         60        OP_DATA                                                  !10
   22    61    >   INIT_FCALL                                               'strtotime'
         62        SEND_VAR                                                 !1
         63        DO_ICALL                                         $45     
         64        INIT_FCALL                                               'strtotime'
         65        SEND_VAR                                                 !11
         66        DO_ICALL                                         $46     
         67        IS_SMALLER_OR_EQUAL                              ~47     $46, $45
         68      > JMPZ_EX                                          ~47     ~47, ->77
         69    >   INIT_FCALL                                               'strtotime'
         70        SEND_VAR                                                 !0
         71        DO_ICALL                                         $48     
         72        INIT_FCALL                                               'strtotime'
         73        SEND_VAR                                                 !11
         74        DO_ICALL                                         $49     
         75        IS_SMALLER_OR_EQUAL                              ~50     $48, $49
         76        BOOL                                             ~47     ~50
         77    > > JMPZ                                                     ~47, ->80
   23    78    >   ASSIGN_DIM                                               !12
         79        OP_DATA                                                  !11
   15    80    > > JMP                                                      ->31
         81    >   FE_FREE                                                  $30
   25    82        INIT_FCALL                                               'print_r'
         83        SEND_VAR                                                 !12
         84        DO_ICALL                                                 
         85      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.46 ms | 1404 KiB | 19 Q