3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "2012-12-08", "2012-12-09", "2012-12-10", "2012-12-11", "2012-12-12", "2012-12-13", "2012-12-14", "2012-12-15" ]; foreach($array as $date) { $on = date("D Y-m-d", strtotime($date)); $week_start = date("D Y-m-d", strtotime("last sunday", strtotime($date))); $week_end = date("D Y-m-d", strtotime("this saturday", strtotime($date))); echo $on." : ".$week_start." -> ".$week_end."\n"; $week_start = date("D Y-m-d", strtotime("last sunday", strtotime('tomorrow', strtotime($date)))); $week_end = date("D Y-m-d", strtotime("this saturday", strtotime('tomorrow', strtotime($date)))); echo $on." : ".$week_start." -> ".$week_end."\n"; $week_start = date("D Y-m-d", strtotime("last sunday tomorrow", strtotime($date))); $week_end = date("D Y-m-d", strtotime("this saturday tomorrow", strtotime($date))); echo $on." : ".$week_start." -> ".$week_end."\n"; $day = date('w', strtotime($date)); $week_start = date('D Y-m-d', strtotime('-'.$day.' days', strtotime($date))); $week_end = date('D Y-m-d', strtotime('+'.(6-$day).' days', strtotime($date))); echo $on." : ".$week_start." -> ".$week_end."\n"; echo "---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 154
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 154
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 154
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 154
filename:       /in/q6kKY
function name:  (null)
number of ops:  156
compiled vars:  !0 = $array, !1 = $date, !2 = $on, !3 = $week_start, !4 = $week_end, !5 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    7     1      > FE_RESET_R                                       $7      !0, ->154
          2    > > FE_FETCH_R                                               $7, !1, ->154
    8     3    >   INIT_FCALL                                               'date'
          4        SEND_VAL                                                 'D+Y-m-d'
          5        INIT_FCALL                                               'strtotime'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $8      
          8        SEND_VAR                                                 $8
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !2, $9
   10    11        INIT_FCALL                                               'date'
         12        SEND_VAL                                                 'D+Y-m-d'
         13        INIT_FCALL                                               'strtotime'
         14        SEND_VAL                                                 'last+sunday'
         15        INIT_FCALL                                               'strtotime'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $11     
         18        SEND_VAR                                                 $11
         19        DO_ICALL                                         $12     
         20        SEND_VAR                                                 $12
         21        DO_ICALL                                         $13     
         22        ASSIGN                                                   !3, $13
   11    23        INIT_FCALL                                               'date'
         24        SEND_VAL                                                 'D+Y-m-d'
         25        INIT_FCALL                                               'strtotime'
         26        SEND_VAL                                                 'this+saturday'
         27        INIT_FCALL                                               'strtotime'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $15     
         30        SEND_VAR                                                 $15
         31        DO_ICALL                                         $16     
         32        SEND_VAR                                                 $16
         33        DO_ICALL                                         $17     
         34        ASSIGN                                                   !4, $17
   12    35        CONCAT                                           ~19     !2, '+%3A+'
         36        CONCAT                                           ~20     ~19, !3
         37        CONCAT                                           ~21     ~20, '+-%3E+'
         38        CONCAT                                           ~22     ~21, !4
         39        CONCAT                                           ~23     ~22, '%0A'
         40        ECHO                                                     ~23
   14    41        INIT_FCALL                                               'date'
         42        SEND_VAL                                                 'D+Y-m-d'
         43        INIT_FCALL                                               'strtotime'
         44        SEND_VAL                                                 'last+sunday'
         45        INIT_FCALL                                               'strtotime'
         46        SEND_VAL                                                 'tomorrow'
         47        INIT_FCALL                                               'strtotime'
         48        SEND_VAR                                                 !1
         49        DO_ICALL                                         $24     
         50        SEND_VAR                                                 $24
         51        DO_ICALL                                         $25     
         52        SEND_VAR                                                 $25
         53        DO_ICALL                                         $26     
         54        SEND_VAR                                                 $26
         55        DO_ICALL                                         $27     
         56        ASSIGN                                                   !3, $27
   15    57        INIT_FCALL                                               'date'
         58        SEND_VAL                                                 'D+Y-m-d'
         59        INIT_FCALL                                               'strtotime'
         60        SEND_VAL                                                 'this+saturday'
         61        INIT_FCALL                                               'strtotime'
         62        SEND_VAL                                                 'tomorrow'
         63        INIT_FCALL                                               'strtotime'
         64        SEND_VAR                                                 !1
         65        DO_ICALL                                         $29     
         66        SEND_VAR                                                 $29
         67        DO_ICALL                                         $30     
         68        SEND_VAR                                                 $30
         69        DO_ICALL                                         $31     
         70        SEND_VAR                                                 $31
         71        DO_ICALL                                         $32     
         72        ASSIGN                                                   !4, $32
   16    73        CONCAT                                           ~34     !2, '+%3A+'
         74        CONCAT                                           ~35     ~34, !3
         75        CONCAT                                           ~36     ~35, '+-%3E+'
         76        CONCAT                                           ~37     ~36, !4
         77        CONCAT                                           ~38     ~37, '%0A'
         78        ECHO                                                     ~38
   18    79        INIT_FCALL                                               'date'
         80        SEND_VAL                                                 'D+Y-m-d'
         81        INIT_FCALL                                               'strtotime'
         82        SEND_VAL                                                 'last+sunday+tomorrow'
         83        INIT_FCALL                                               'strtotime'
         84        SEND_VAR                                                 !1
         85        DO_ICALL                                         $39     
         86        SEND_VAR                                                 $39
         87        DO_ICALL                                         $40     
         88        SEND_VAR                                                 $40
         89        DO_ICALL                                         $41     
         90        ASSIGN                                                   !3, $41
   19    91        INIT_FCALL                                               'date'
         92        SEND_VAL                                                 'D+Y-m-d'
         93        INIT_FCALL                                               'strtotime'
         94        SEND_VAL                                                 'this+saturday+tomorrow'
         95        INIT_FCALL                                               'strtotime'
         96        SEND_VAR                                                 !1
         97        DO_ICALL                                         $43     
         98        SEND_VAR                                                 $43
         99        DO_ICALL                                         $44     
        100        SEND_VAR                                                 $44
        101        DO_ICALL                                         $45     
        102        ASSIGN                                                   !4, $45
   20   103        CONCAT                                           ~47     !2, '+%3A+'
        104        CONCAT                                           ~48     ~47, !3
        105        CONCAT                                           ~49     ~48, '+-%3E+'
        106        CONCAT                                           ~50     ~49, !4
        107        CONCAT                                           ~51     ~50, '%0A'
        108        ECHO                                                     ~51
   22   109        INIT_FCALL                                               'date'
        110        SEND_VAL                                                 'w'
        111        INIT_FCALL                                               'strtotime'
        112        SEND_VAR                                                 !1
        113        DO_ICALL                                         $52     
        114        SEND_VAR                                                 $52
        115        DO_ICALL                                         $53     
        116        ASSIGN                                                   !5, $53
   23   117        INIT_FCALL                                               'date'
        118        SEND_VAL                                                 'D+Y-m-d'
        119        INIT_FCALL                                               'strtotime'
        120        CONCAT                                           ~55     '-', !5
        121        CONCAT                                           ~56     ~55, '+days'
        122        SEND_VAL                                                 ~56
        123        INIT_FCALL                                               'strtotime'
        124        SEND_VAR                                                 !1
        125        DO_ICALL                                         $57     
        126        SEND_VAR                                                 $57
        127        DO_ICALL                                         $58     
        128        SEND_VAR                                                 $58
        129        DO_ICALL                                         $59     
        130        ASSIGN                                                   !3, $59
   24   131        INIT_FCALL                                               'date'
        132        SEND_VAL                                                 'D+Y-m-d'
        133        INIT_FCALL                                               'strtotime'
        134        SUB                                              ~61     6, !5
        135        CONCAT                                           ~62     '%2B', ~61
        136        CONCAT                                           ~63     ~62, '+days'
        137        SEND_VAL                                                 ~63
        138        INIT_FCALL                                               'strtotime'
        139        SEND_VAR                                                 !1
        140        DO_ICALL                                         $64     
        141        SEND_VAR                                                 $64
        142        DO_ICALL                                         $65     
        143        SEND_VAR                                                 $65
        144        DO_ICALL                                         $66     
        145        ASSIGN                                                   !4, $66
   25   146        CONCAT                                           ~68     !2, '+%3A+'
        147        CONCAT                                           ~69     ~68, !3
        148        CONCAT                                           ~70     ~69, '+-%3E+'
        149        CONCAT                                           ~71     ~70, !4
        150        CONCAT                                           ~72     ~71, '%0A'
        151        ECHO                                                     ~72
   26   152        ECHO                                                     '---%0A'
    7   153      > JMP                                                      ->2
        154    >   FE_FREE                                                  $7
   27   155      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.88 ms | 1012 KiB | 15 Q