3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPlayDays($startWeek, $numWeeks) { $numWeeks --; $result = []; $currYear = (int)(new \DateTime())->format('Y'); $oneDay = new \DateInterval('P1D'); // Start on the first Thursday of the given week. $startDate = (new \DateTime())->setISODate($currYear, $startWeek, 4); $endDate = clone $startDate; $endDate->add(new \DateInterval("P{$numWeeks}W")); // End on the Sunday of the last week. $endDate->setISODate((int)$endDate->format('o'), (int)$endDate->format('W'), 7); $period = new \DatePeriod($startDate, $oneDay, $endDate->add($oneDay)); foreach($period as $day){ if(4 === (int)$day->format('N') || 7 === (int)$day->format('N') ){ $result[] = $day; } } return $result; } foreach(getPlayDays(1, 3) as $playDay){ var_dump($playDay->format('D m-d-Y')); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/P9VHA
function name:  (null)
number of ops:  15
compiled vars:  !0 = $playDay
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'getplaydays'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 3
          3        DO_FCALL                                      0  $1      
          4      > FE_RESET_R                                       $2      $1, ->13
          5    > > FE_FETCH_R                                               $2, !0, ->13
   28     6    >   INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'format'
          8        SEND_VAL_EX                                              'D+m-d-Y'
          9        DO_FCALL                                      0  $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                                 
   27    12      > JMP                                                      ->5
         13    >   FE_FREE                                                  $2
   29    14      > RETURN                                                   1

Function getplaydays:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 57, Position 2 = 74
Branch analysis from position: 57
2 jumps found. (Code = 78) Position 1 = 58, Position 2 = 74
Branch analysis from position: 58
2 jumps found. (Code = 47) Position 1 = 64, Position 2 = 70
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 73
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 73
Branch analysis from position: 70
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
filename:       /in/P9VHA
function name:  getPlayDays
number of ops:  77
compiled vars:  !0 = $startWeek, !1 = $numWeeks, !2 = $result, !3 = $currYear, !4 = $oneDay, !5 = $startDate, !6 = $endDate, !7 = $period, !8 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        PRE_DEC                                                  !1
    5     3        ASSIGN                                                   !2, <array>
    6     4        NEW                                              $11     'DateTime'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $11, 'format'
          7        SEND_VAL_EX                                              'Y'
          8        DO_FCALL                                      0  $13     
          9        CAST                                          4  ~14     $13
         10        ASSIGN                                                   !3, ~14
    7    11        NEW                                              $16     'DateInterval'
         12        SEND_VAL_EX                                              'P1D'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !4, $16
    9    15        NEW                                              $19     'DateTime'
         16        DO_FCALL                                      0          
         17        INIT_METHOD_CALL                                         $19, 'setISODate'
         18        SEND_VAR_EX                                              !3
         19        SEND_VAR_EX                                              !0
         20        SEND_VAL_EX                                              4
         21        DO_FCALL                                      0  $21     
         22        ASSIGN                                                   !5, $21
   11    23        CLONE                                            ~23     !5
         24        ASSIGN                                                   !6, ~23
   12    25        INIT_METHOD_CALL                                         !6, 'add'
         26        NEW                                              $25     'DateInterval'
         27        ROPE_INIT                                     3  ~27     'P'
         28        ROPE_ADD                                      1  ~27     ~27, !1
         29        ROPE_END                                      2  ~26     ~27, 'W'
         30        SEND_VAL_EX                                              ~26
         31        DO_FCALL                                      0          
         32        SEND_VAR_NO_REF_EX                                       $25
         33        DO_FCALL                                      0          
   15    34        INIT_METHOD_CALL                                         !6, 'setISODate'
         35        INIT_METHOD_CALL                                         !6, 'format'
         36        SEND_VAL_EX                                              'o'
         37        DO_FCALL                                      0  $31     
         38        CAST                                          4  ~32     $31
         39        SEND_VAL_EX                                              ~32
         40        INIT_METHOD_CALL                                         !6, 'format'
         41        SEND_VAL_EX                                              'W'
         42        DO_FCALL                                      0  $33     
         43        CAST                                          4  ~34     $33
         44        SEND_VAL_EX                                              ~34
         45        SEND_VAL_EX                                              7
         46        DO_FCALL                                      0          
   17    47        NEW                                              $36     'DatePeriod'
         48        SEND_VAR_EX                                              !5
         49        SEND_VAR_EX                                              !4
         50        INIT_METHOD_CALL                                         !6, 'add'
         51        SEND_VAR_EX                                              !4
         52        DO_FCALL                                      0  $37     
         53        SEND_VAR_NO_REF_EX                                       $37
         54        DO_FCALL                                      0          
         55        ASSIGN                                                   !7, $36
   19    56      > FE_RESET_R                                       $40     !7, ->74
         57    > > FE_FETCH_R                                               $40, !8, ->74
   20    58    >   INIT_METHOD_CALL                                         !8, 'format'
         59        SEND_VAL_EX                                              'N'
         60        DO_FCALL                                      0  $41     
         61        CAST                                          4  ~42     $41
         62        IS_IDENTICAL                                     ~43     ~42, 4
         63      > JMPNZ_EX                                         ~43     ~43, ->70
         64    >   INIT_METHOD_CALL                                         !8, 'format'
         65        SEND_VAL_EX                                              'N'
         66        DO_FCALL                                      0  $44     
         67        CAST                                          4  ~45     $44
         68        IS_IDENTICAL                                     ~46     ~45, 7
         69        BOOL                                             ~43     ~46
         70    > > JMPZ                                                     ~43, ->73
   21    71    >   ASSIGN_DIM                                               !2
         72        OP_DATA                                                  !8
   19    73    > > JMP                                                      ->57
         74    >   FE_FREE                                                  $40
   24    75      > RETURN                                                   !2
   25    76*     > RETURN                                                   null

End of function getplaydays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.62 ms | 1407 KiB | 16 Q