3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start_date = '2014-3-19'; $end_date = '2014-5-19'; $begin = new DateTime( $start_date ); $end = new DateTime(date("Y-m-d",strtotime("+1 day", strtotime($end_date)))); while($begin < $end) { if(isWeekend($begin->format('Y-m-d'))) $period[] = $begin->format('Y-m-d'); $begin->modify('+1 day'); } foreach($period as $val) { print_r("Value: " . $val . (isWeekend($val) ? " - weekend\n" : " - weekday\n")); } function isWeekend($date) { return (date('N', strtotime($date)) >= 6); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 22
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 54
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 54
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 22
Branch analysis from position: 39
Branch analysis from position: 22
Branch analysis from position: 34
filename:       /in/r4Hsk
function name:  (null)
number of ops:  56
compiled vars:  !0 = $start_date, !1 = $end_date, !2 = $begin, !3 = $end, !4 = $period, !5 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2014-3-19'
    4     1        ASSIGN                                                   !1, '2014-5-19'
    6     2        NEW                                              $8      'DateTime'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $8
    7     6        NEW                                              $11     'DateTime'
          7        INIT_FCALL                                               'date'
          8        SEND_VAL                                                 'Y-m-d'
          9        INIT_FCALL                                               'strtotime'
         10        SEND_VAL                                                 '%2B1+day'
         11        INIT_FCALL                                               'strtotime'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $12     
         14        SEND_VAR                                                 $12
         15        DO_ICALL                                         $13     
         16        SEND_VAR                                                 $13
         17        DO_ICALL                                         $14     
         18        SEND_VAR_NO_REF_EX                                       $14
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !3, $11
    8    21      > JMP                                                      ->37
    9    22    >   INIT_FCALL_BY_NAME                                       'isWeekend'
         23        INIT_METHOD_CALL                                         !2, 'format'
         24        SEND_VAL_EX                                              'Y-m-d'
         25        DO_FCALL                                      0  $17     
         26        SEND_VAR_NO_REF_EX                                       $17
         27        DO_FCALL                                      0  $18     
         28      > JMPZ                                                     $18, ->34
   10    29    >   INIT_METHOD_CALL                                         !2, 'format'
         30        SEND_VAL_EX                                              'Y-m-d'
         31        DO_FCALL                                      0  $20     
         32        ASSIGN_DIM                                               !4
         33        OP_DATA                                                  $20
   11    34    >   INIT_METHOD_CALL                                         !2, 'modify'
         35        SEND_VAL_EX                                              '%2B1+day'
         36        DO_FCALL                                      0          
    8    37    >   IS_SMALLER                                               !2, !3
         38      > JMPNZ                                                    ~22, ->22
   14    39    > > FE_RESET_R                                       $23     !4, ->54
         40    > > FE_FETCH_R                                               $23, !5, ->54
   15    41    >   INIT_FCALL                                               'print_r'
         42        CONCAT                                           ~24     'Value%3A+', !5
         43        INIT_FCALL_BY_NAME                                       'isWeekend'
         44        SEND_VAR_EX                                              !5
         45        DO_FCALL                                      0  $25     
         46      > JMPZ                                                     $25, ->49
         47    >   QM_ASSIGN                                        ~26     '+-+weekend%0A'
         48      > JMP                                                      ->50
         49    >   QM_ASSIGN                                        ~26     '+-+weekday%0A'
         50    >   CONCAT                                           ~27     ~24, ~26
         51        SEND_VAL                                                 ~27
         52        DO_ICALL                                                 
   14    53      > JMP                                                      ->40
         54    >   FE_FREE                                                  $23
   20    55      > RETURN                                                   1

Function isweekend:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r4Hsk
function name:  isWeekend
number of ops:  11
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'N'
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                         $2      
          8        IS_SMALLER_OR_EQUAL                              ~3      6, $2
          9      > RETURN                                                   ~3
   20    10*     > RETURN                                                   null

End of function isweekend

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.47 ms | 1400 KiB | 19 Q