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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.85 ms | 1408 KiB | 19 Q