3v4l.org

run code in 300+ PHP versions simultaneously
<?php $month=10; $year=2014; // Mantech $startDate = strtotime($month.'/1/'.$year); $stopDate = strtotime('last day of this month ',$startDate); if (date('D',$startDate)!='Sat'){ $startDate = strtotime('next saturday',$startDate); } if (date('D',$stopDate)!='Fri'){ $stopDate = strtotime('next friday',$stopDate); } echo (date('Y-m-d',$startDate).' - '.date('Y-m-d',$stopDate)."\n"); // If our startDate isn't a Monday, grab the previous Monday if (date('D',$startDate)!='Mon'){ $prevMonday = strtotime('last Monday',$startDate); $startWeek = date('W',$prevMonday); } else { $startWeek = date('W',$startDate); } $stopWeek = date('W',$stopDate); // Format startweek as ISO8601 eg.2014W15 $beginWeek = date('o',$startWeek).'W'.date('W',$startWeek); for ($i=0; $i<=$stopWeek-$startWeek; $i++){ $thisWeek = strtotime($beginWeek.' +'.$i.' weeks'); echo (date('Y-m-d',$thisWeek)."\n"); $mask = ''; for ($j=0; $j<7; $j++){ $thisDay = strtotime('+'.$j.' days',$thisWeek); if ($startDate<=$thisDay or $thisDay<=$stopDate){ $mask=$mask.'1'; } else { $mask=$mask.'0'; } } echo $mask."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 64
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 126
Branch analysis from position: 126
2 jumps found. (Code = 44) Position 1 = 129, Position 2 = 87
Branch analysis from position: 129
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 87
1 jumps found. (Code = 42) Position 1 = 121
Branch analysis from position: 121
2 jumps found. (Code = 44) Position 1 = 123, Position 2 = 103
Branch analysis from position: 123
2 jumps found. (Code = 44) Position 1 = 129, Position 2 = 87
Branch analysis from position: 129
Branch analysis from position: 87
Branch analysis from position: 103
2 jumps found. (Code = 47) Position 1 = 112, Position 2 = 114
Branch analysis from position: 112
2 jumps found. (Code = 43) Position 1 = 115, Position 2 = 118
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 120
Branch analysis from position: 120
2 jumps found. (Code = 44) Position 1 = 123, Position 2 = 103
Branch analysis from position: 123
Branch analysis from position: 103
Branch analysis from position: 118
2 jumps found. (Code = 44) Position 1 = 123, Position 2 = 103
Branch analysis from position: 123
Branch analysis from position: 103
Branch analysis from position: 114
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 126
Branch analysis from position: 126
Branch analysis from position: 35
Branch analysis from position: 24
filename:       /in/BnU3k
function name:  (null)
number of ops:  130
compiled vars:  !0 = $month, !1 = $year, !2 = $startDate, !3 = $stopDate, !4 = $prevMonday, !5 = $startWeek, !6 = $stopWeek, !7 = $beginWeek, !8 = $i, !9 = $thisWeek, !10 = $mask, !11 = $j, !12 = $thisDay
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 10
    3     1        ASSIGN                                                   !1, 2014
    6     2        INIT_FCALL                                               'strtotime'
          3        CONCAT                                           ~15     !0, '%2F1%2F'
          4        CONCAT                                           ~16     ~15, !1
          5        SEND_VAL                                                 ~16
          6        DO_ICALL                                         $17     
          7        ASSIGN                                                   !2, $17
    7     8        INIT_FCALL                                               'strtotime'
          9        SEND_VAL                                                 'last+day+of+this+month+'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $19     
         12        ASSIGN                                                   !3, $19
    9    13        INIT_FCALL                                               'date'
         14        SEND_VAL                                                 'D'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $21     
         17        IS_NOT_EQUAL                                             $21, 'Sat'
         18      > JMPZ                                                     ~22, ->24
   10    19    >   INIT_FCALL                                               'strtotime'
         20        SEND_VAL                                                 'next+saturday'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $23     
         23        ASSIGN                                                   !2, $23
   12    24    >   INIT_FCALL                                               'date'
         25        SEND_VAL                                                 'D'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                         $25     
         28        IS_NOT_EQUAL                                             $25, 'Fri'
         29      > JMPZ                                                     ~26, ->35
   13    30    >   INIT_FCALL                                               'strtotime'
         31        SEND_VAL                                                 'next+friday'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                         $27     
         34        ASSIGN                                                   !3, $27
   16    35    >   INIT_FCALL                                               'date'
         36        SEND_VAL                                                 'Y-m-d'
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                         $29     
         39        CONCAT                                           ~30     $29, '+-+'
         40        INIT_FCALL                                               'date'
         41        SEND_VAL                                                 'Y-m-d'
         42        SEND_VAR                                                 !3
         43        DO_ICALL                                         $31     
         44        CONCAT                                           ~32     ~30, $31
         45        CONCAT                                           ~33     ~32, '%0A'
         46        ECHO                                                     ~33
   19    47        INIT_FCALL                                               'date'
         48        SEND_VAL                                                 'D'
         49        SEND_VAR                                                 !2
         50        DO_ICALL                                         $34     
         51        IS_NOT_EQUAL                                             $34, 'Mon'
         52      > JMPZ                                                     ~35, ->64
   20    53    >   INIT_FCALL                                               'strtotime'
         54        SEND_VAL                                                 'last+Monday'
         55        SEND_VAR                                                 !2
         56        DO_ICALL                                         $36     
         57        ASSIGN                                                   !4, $36
   21    58        INIT_FCALL                                               'date'
         59        SEND_VAL                                                 'W'
         60        SEND_VAR                                                 !4
         61        DO_ICALL                                         $38     
         62        ASSIGN                                                   !5, $38
         63      > JMP                                                      ->69
   23    64    >   INIT_FCALL                                               'date'
         65        SEND_VAL                                                 'W'
         66        SEND_VAR                                                 !2
         67        DO_ICALL                                         $40     
         68        ASSIGN                                                   !5, $40
   25    69    >   INIT_FCALL                                               'date'
         70        SEND_VAL                                                 'W'
         71        SEND_VAR                                                 !3
         72        DO_ICALL                                         $42     
         73        ASSIGN                                                   !6, $42
   28    74        INIT_FCALL                                               'date'
         75        SEND_VAL                                                 'o'
         76        SEND_VAR                                                 !5
         77        DO_ICALL                                         $44     
         78        CONCAT                                           ~45     $44, 'W'
         79        INIT_FCALL                                               'date'
         80        SEND_VAL                                                 'W'
         81        SEND_VAR                                                 !5
         82        DO_ICALL                                         $46     
         83        CONCAT                                           ~47     ~45, $46
         84        ASSIGN                                                   !7, ~47
   30    85        ASSIGN                                                   !8, 0
         86      > JMP                                                      ->126
   31    87    >   INIT_FCALL                                               'strtotime'
         88        CONCAT                                           ~50     !7, '+%2B'
         89        CONCAT                                           ~51     ~50, !8
         90        CONCAT                                           ~52     ~51, '+weeks'
         91        SEND_VAL                                                 ~52
         92        DO_ICALL                                         $53     
         93        ASSIGN                                                   !9, $53
   32    94        INIT_FCALL                                               'date'
         95        SEND_VAL                                                 'Y-m-d'
         96        SEND_VAR                                                 !9
         97        DO_ICALL                                         $55     
         98        CONCAT                                           ~56     $55, '%0A'
         99        ECHO                                                     ~56
   33   100        ASSIGN                                                   !10, ''
   34   101        ASSIGN                                                   !11, 0
        102      > JMP                                                      ->121
   35   103    >   INIT_FCALL                                               'strtotime'
        104        CONCAT                                           ~59     '%2B', !11
        105        CONCAT                                           ~60     ~59, '+days'
        106        SEND_VAL                                                 ~60
        107        SEND_VAR                                                 !9
        108        DO_ICALL                                         $61     
        109        ASSIGN                                                   !12, $61
   36   110        IS_SMALLER_OR_EQUAL                              ~63     !2, !12
        111      > JMPNZ_EX                                         ~63     ~63, ->114
        112    >   IS_SMALLER_OR_EQUAL                              ~64     !12, !3
        113        BOOL                                             ~63     ~64
        114    > > JMPZ                                                     ~63, ->118
   37   115    >   CONCAT                                           ~65     !10, '1'
        116        ASSIGN                                                   !10, ~65
        117      > JMP                                                      ->120
   39   118    >   CONCAT                                           ~67     !10, '0'
        119        ASSIGN                                                   !10, ~67
   34   120    >   PRE_INC                                                  !11
        121    >   IS_SMALLER                                               !11, 7
        122      > JMPNZ                                                    ~70, ->103
   42   123    >   CONCAT                                           ~71     !10, '%0A'
        124        ECHO                                                     ~71
   30   125        PRE_INC                                                  !8
        126    >   SUB                                              ~73     !6, !5
        127        IS_SMALLER_OR_EQUAL                                      !8, ~73
        128      > JMPNZ                                                    ~74, ->87
   43   129    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154 ms | 1408 KiB | 17 Q