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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.83 ms | 1408 KiB | 17 Q