3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.9 ms | 1404 KiB | 19 Q