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); echo $beginWeek; echo (date('Y-m-d',strtotime($beginWeek))."\n"); 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 = 136
Branch analysis from position: 136
2 jumps found. (Code = 44) Position 1 = 139, Position 2 = 97
Branch analysis from position: 139
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 131
Branch analysis from position: 131
2 jumps found. (Code = 44) Position 1 = 133, Position 2 = 113
Branch analysis from position: 133
2 jumps found. (Code = 44) Position 1 = 139, Position 2 = 97
Branch analysis from position: 139
Branch analysis from position: 97
Branch analysis from position: 113
2 jumps found. (Code = 47) Position 1 = 122, Position 2 = 124
Branch analysis from position: 122
2 jumps found. (Code = 43) Position 1 = 125, Position 2 = 128
Branch analysis from position: 125
1 jumps found. (Code = 42) Position 1 = 130
Branch analysis from position: 130
2 jumps found. (Code = 44) Position 1 = 133, Position 2 = 113
Branch analysis from position: 133
Branch analysis from position: 113
Branch analysis from position: 128
2 jumps found. (Code = 44) Position 1 = 133, Position 2 = 113
Branch analysis from position: 133
Branch analysis from position: 113
Branch analysis from position: 124
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 136
Branch analysis from position: 136
Branch analysis from position: 35
Branch analysis from position: 24
filename:       /in/JW73Q
function name:  (null)
number of ops:  140
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        ECHO                                                     !7
   31    86        INIT_FCALL                                               'date'
         87        SEND_VAL                                                 'Y-m-d'
         88        INIT_FCALL                                               'strtotime'
         89        SEND_VAR                                                 !7
         90        DO_ICALL                                         $49     
         91        SEND_VAR                                                 $49
         92        DO_ICALL                                         $50     
         93        CONCAT                                           ~51     $50, '%0A'
         94        ECHO                                                     ~51
   33    95        ASSIGN                                                   !8, 0
         96      > JMP                                                      ->136
   34    97    >   INIT_FCALL                                               'strtotime'
         98        CONCAT                                           ~53     !7, '+%2B'
         99        CONCAT                                           ~54     ~53, !8
        100        CONCAT                                           ~55     ~54, '+weeks'
        101        SEND_VAL                                                 ~55
        102        DO_ICALL                                         $56     
        103        ASSIGN                                                   !9, $56
   36   104        INIT_FCALL                                               'date'
        105        SEND_VAL                                                 'Y-m-d'
        106        SEND_VAR                                                 !9
        107        DO_ICALL                                         $58     
        108        CONCAT                                           ~59     $58, '%0A'
        109        ECHO                                                     ~59
   38   110        ASSIGN                                                   !10, ''
   39   111        ASSIGN                                                   !11, 0
        112      > JMP                                                      ->131
   40   113    >   INIT_FCALL                                               'strtotime'
        114        CONCAT                                           ~62     '%2B', !11
        115        CONCAT                                           ~63     ~62, '+days'
        116        SEND_VAL                                                 ~63
        117        SEND_VAR                                                 !9
        118        DO_ICALL                                         $64     
        119        ASSIGN                                                   !12, $64
   41   120        IS_SMALLER_OR_EQUAL                              ~66     !2, !12
        121      > JMPNZ_EX                                         ~66     ~66, ->124
        122    >   IS_SMALLER_OR_EQUAL                              ~67     !12, !3
        123        BOOL                                             ~66     ~67
        124    > > JMPZ                                                     ~66, ->128
   42   125    >   CONCAT                                           ~68     !10, '1'
        126        ASSIGN                                                   !10, ~68
        127      > JMP                                                      ->130
   44   128    >   CONCAT                                           ~70     !10, '0'
        129        ASSIGN                                                   !10, ~70
   39   130    >   PRE_INC                                                  !11
        131    >   IS_SMALLER                                               !11, 7
        132      > JMPNZ                                                    ~73, ->113
   47   133    >   CONCAT                                           ~74     !10, '%0A'
        134        ECHO                                                     ~74
   33   135        PRE_INC                                                  !8
        136    >   SUB                                              ~76     !6, !5
        137        IS_SMALLER_OR_EQUAL                                      !8, ~76
        138      > JMPNZ                                                    ~77, ->97
   48   139    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.96 ms | 1408 KiB | 17 Q