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); } // 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'); $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"; } echo (date('Y-m-d',$startDate).' - '.date('Y-m-d',$stopDate)."\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 = 41, Position 2 = 52
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 75
Branch analysis from position: 111
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
2 jumps found. (Code = 44) Position 1 = 105, Position 2 = 85
Branch analysis from position: 105
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 75
Branch analysis from position: 111
Branch analysis from position: 75
Branch analysis from position: 85
2 jumps found. (Code = 47) Position 1 = 94, Position 2 = 96
Branch analysis from position: 94
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 100
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
2 jumps found. (Code = 44) Position 1 = 105, Position 2 = 85
Branch analysis from position: 105
Branch analysis from position: 85
Branch analysis from position: 100
2 jumps found. (Code = 44) Position 1 = 105, Position 2 = 85
Branch analysis from position: 105
Branch analysis from position: 85
Branch analysis from position: 96
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
Branch analysis from position: 35
Branch analysis from position: 24
filename:       /in/glDJb
function name:  (null)
number of ops:  124
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
   17    35    >   INIT_FCALL                                               'date'
         36        SEND_VAL                                                 'D'
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                         $29     
         39        IS_NOT_EQUAL                                             $29, 'Mon'
         40      > JMPZ                                                     ~30, ->52
   18    41    >   INIT_FCALL                                               'strtotime'
         42        SEND_VAL                                                 'last+Monday'
         43        SEND_VAR                                                 !2
         44        DO_ICALL                                         $31     
         45        ASSIGN                                                   !4, $31
   19    46        INIT_FCALL                                               'date'
         47        SEND_VAL                                                 'W'
         48        SEND_VAR                                                 !4
         49        DO_ICALL                                         $33     
         50        ASSIGN                                                   !5, $33
         51      > JMP                                                      ->57
   21    52    >   INIT_FCALL                                               'date'
         53        SEND_VAL                                                 'W'
         54        SEND_VAR                                                 !2
         55        DO_ICALL                                         $35     
         56        ASSIGN                                                   !5, $35
   23    57    >   INIT_FCALL                                               'date'
         58        SEND_VAL                                                 'W'
         59        SEND_VAR                                                 !3
         60        DO_ICALL                                         $37     
         61        ASSIGN                                                   !6, $37
   26    62        INIT_FCALL                                               'date'
         63        SEND_VAL                                                 'o'
         64        SEND_VAR                                                 !5
         65        DO_ICALL                                         $39     
         66        CONCAT                                           ~40     $39, 'W'
         67        INIT_FCALL                                               'date'
         68        SEND_VAL                                                 'W'
         69        SEND_VAR                                                 !5
         70        DO_ICALL                                         $41     
         71        CONCAT                                           ~42     ~40, $41
         72        ASSIGN                                                   !7, ~42
   28    73        ASSIGN                                                   !8, 0
         74      > JMP                                                      ->108
   29    75    >   INIT_FCALL                                               'strtotime'
         76        CONCAT                                           ~45     !7, '+%2B'
         77        CONCAT                                           ~46     ~45, !8
         78        CONCAT                                           ~47     ~46, '+weeks'
         79        SEND_VAL                                                 ~47
         80        DO_ICALL                                         $48     
         81        ASSIGN                                                   !9, $48
   30    82        ASSIGN                                                   !10, ''
   31    83        ASSIGN                                                   !11, 0
         84      > JMP                                                      ->103
   32    85    >   INIT_FCALL                                               'strtotime'
         86        CONCAT                                           ~52     '%2B', !11
         87        CONCAT                                           ~53     ~52, '+days'
         88        SEND_VAL                                                 ~53
         89        SEND_VAR                                                 !9
         90        DO_ICALL                                         $54     
         91        ASSIGN                                                   !12, $54
   33    92        IS_SMALLER_OR_EQUAL                              ~56     !2, !12
         93      > JMPNZ_EX                                         ~56     ~56, ->96
         94    >   IS_SMALLER_OR_EQUAL                              ~57     !12, !3
         95        BOOL                                             ~56     ~57
         96    > > JMPZ                                                     ~56, ->100
   34    97    >   CONCAT                                           ~58     !10, '1'
         98        ASSIGN                                                   !10, ~58
         99      > JMP                                                      ->102
   36   100    >   CONCAT                                           ~60     !10, '0'
        101        ASSIGN                                                   !10, ~60
   31   102    >   PRE_INC                                                  !11
        103    >   IS_SMALLER                                               !11, 7
        104      > JMPNZ                                                    ~63, ->85
   39   105    >   CONCAT                                           ~64     !10, '%0A'
        106        ECHO                                                     ~64
   28   107        PRE_INC                                                  !8
        108    >   SUB                                              ~66     !6, !5
        109        IS_SMALLER_OR_EQUAL                                      !8, ~66
        110      > JMPNZ                                                    ~67, ->75
   43   111    >   INIT_FCALL                                               'date'
        112        SEND_VAL                                                 'Y-m-d'
        113        SEND_VAR                                                 !2
        114        DO_ICALL                                         $68     
        115        CONCAT                                           ~69     $68, '+-+'
        116        INIT_FCALL                                               'date'
        117        SEND_VAL                                                 'Y-m-d'
        118        SEND_VAR                                                 !3
        119        DO_ICALL                                         $70     
        120        CONCAT                                           ~71     ~69, $70
        121        CONCAT                                           ~72     ~71, '%0A'
        122        ECHO                                                     ~72
        123      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.97 ms | 1408 KiB | 17 Q