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)) $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 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 22
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 51
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 51
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 22
Branch analysis from position: 36
Branch analysis from position: 22
Branch analysis from position: 31
filename:       /in/e6dXd
function name:  (null)
number of ops:  53
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                                                      ->34
    9    22    >   INIT_FCALL_BY_NAME                                       'isWeekend'
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0  $17     
         25      > JMPZ                                                     $17, ->31
   10    26    >   INIT_METHOD_CALL                                         !2, 'format'
         27        SEND_VAL_EX                                              'Y-m-d'
         28        DO_FCALL                                      0  $19     
         29        ASSIGN_DIM                                               !4
         30        OP_DATA                                                  $19
   11    31    >   INIT_METHOD_CALL                                         !2, 'modify'
         32        SEND_VAL_EX                                              '%2B1+day'
         33        DO_FCALL                                      0          
    8    34    >   IS_SMALLER                                               !2, !3
         35      > JMPNZ                                                    ~21, ->22
   14    36    > > FE_RESET_R                                       $22     !4, ->51
         37    > > FE_FETCH_R                                               $22, !5, ->51
   15    38    >   INIT_FCALL                                               'print_r'
         39        CONCAT                                           ~23     'Value%3A+', !5
         40        INIT_FCALL_BY_NAME                                       'isWeekend'
         41        SEND_VAR_EX                                              !5
         42        DO_FCALL                                      0  $24     
         43      > JMPZ                                                     $24, ->46
         44    >   QM_ASSIGN                                        ~25     '+-+weekend%0A'
         45      > JMP                                                      ->47
         46    >   QM_ASSIGN                                        ~25     '+-+weekday%0A'
         47    >   CONCAT                                           ~26     ~23, ~25
         48        SEND_VAL                                                 ~26
         49        DO_ICALL                                                 
   14    50      > JMP                                                      ->37
         51    >   FE_FREE                                                  $22
   20    52      > RETURN                                                   1

Function isweekend:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e6dXd
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:
165.41 ms | 945 KiB | 20 Q