3v4l.org

run code in 300+ PHP versions simultaneously
<?php function week_from_monday($date) { // Assuming $date is in format DD-MM-YYYY list($day, $month, $year) = explode("-", $_REQUEST["date"]); // Get the weekday of the given date $wkday = date('l',mktime('0','0','0', $month, $day, $year)); switch($wkday) { case 'Monday': $numDaysToMon = 0; break; case 'Tuesday': $numDaysToMon = 1; break; case 'Wednesday': $numDaysToMon = 2; break; case 'Thursday': $numDaysToMon = 3; break; case 'Friday': $numDaysToMon = 4; break; case 'Saturday': $numDaysToMon = 5; break; case 'Sunday': $numDaysToMon = 6; break; } // Timestamp of the monday for that week $monday = mktime('0','0','0', $month, $day-$numDaysToMon, $year); $seconds_in_a_day = 86400; // Get date for 7 days from Monday (inclusive) for($i=0; $i<7; $i++) { $dates[$i] = date('Y-m-d',$monday+($seconds_in_a_day*$i)); } return $dates; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PgKol
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E > > RETURN                                                   1

Function week_from_monday:
Finding entry points
Branch analysis from position: 0
9 jumps found. (Code = 188) Position 1 = 43, Position 2 = 45, Position 3 = 47, Position 4 = 49, Position 5 = 51, Position 6 = 53, Position 7 = 55, Position 8 = 57, Position 9 = 28
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
2 jumps found. (Code = 44) Position 1 = 81, Position 2 = 70
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 81, Position 2 = 70
Branch analysis from position: 81
Branch analysis from position: 70
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 57
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 43
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 45
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 47
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 49
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 51
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 53
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 55
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 55
Branch analysis from position: 53
Branch analysis from position: 51
Branch analysis from position: 49
Branch analysis from position: 47
Branch analysis from position: 45
Branch analysis from position: 43
filename:       /in/PgKol
function name:  week_from_monday
number of ops:  83
compiled vars:  !0 = $date, !1 = $day, !2 = $month, !3 = $year, !4 = $wkday, !5 = $numDaysToMon, !6 = $monday, !7 = $seconds_in_a_day, !8 = $i, !9 = $dates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '-'
          3        FETCH_R                      global              ~10     '_REQUEST'
          4        FETCH_DIM_R                                      ~11     ~10, 'date'
          5        SEND_VAL                                                 ~11
          6        DO_ICALL                                         $12     
          7        FETCH_LIST_R                                     $13     $12, 0
          8        ASSIGN                                                   !1, $13
          9        FETCH_LIST_R                                     $15     $12, 1
         10        ASSIGN                                                   !2, $15
         11        FETCH_LIST_R                                     $17     $12, 2
         12        ASSIGN                                                   !3, $17
         13        FREE                                                     $12
    7    14        INIT_FCALL                                               'date'
         15        SEND_VAL                                                 'l'
         16        INIT_FCALL                                               'mktime'
         17        SEND_VAL                                                 '0'
         18        SEND_VAL                                                 '0'
         19        SEND_VAL                                                 '0'
         20        SEND_VAR                                                 !2
         21        SEND_VAR                                                 !1
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $19     
         24        SEND_VAR                                                 $19
         25        DO_ICALL                                         $20     
         26        ASSIGN                                                   !4, $20
    9    27      > SWITCH_STRING                                            !4, [ 'Monday':->43, 'Tuesday':->45, 'Wednesday':->47, 'Thursday':->49, 'Friday':->51, 'Saturday':->53, 'Sunday':->55, ], ->57
   10    28    >   IS_EQUAL                                                 !4, 'Monday'
         29      > JMPNZ                                                    ~22, ->43
   11    30    >   IS_EQUAL                                                 !4, 'Tuesday'
         31      > JMPNZ                                                    ~22, ->45
   12    32    >   IS_EQUAL                                                 !4, 'Wednesday'
         33      > JMPNZ                                                    ~22, ->47
   13    34    >   IS_EQUAL                                                 !4, 'Thursday'
         35      > JMPNZ                                                    ~22, ->49
   14    36    >   IS_EQUAL                                                 !4, 'Friday'
         37      > JMPNZ                                                    ~22, ->51
   15    38    >   IS_EQUAL                                                 !4, 'Saturday'
         39      > JMPNZ                                                    ~22, ->53
   16    40    >   IS_EQUAL                                                 !4, 'Sunday'
         41      > JMPNZ                                                    ~22, ->55
         42    > > JMP                                                      ->57
   10    43    >   ASSIGN                                                   !5, 0
         44      > JMP                                                      ->57
   11    45    >   ASSIGN                                                   !5, 1
         46      > JMP                                                      ->57
   12    47    >   ASSIGN                                                   !5, 2
         48      > JMP                                                      ->57
   13    49    >   ASSIGN                                                   !5, 3
         50      > JMP                                                      ->57
   14    51    >   ASSIGN                                                   !5, 4
         52      > JMP                                                      ->57
   15    53    >   ASSIGN                                                   !5, 5
         54      > JMP                                                      ->57
   16    55    >   ASSIGN                                                   !5, 6
         56      > JMP                                                      ->57
   20    57    >   INIT_FCALL                                               'mktime'
         58        SEND_VAL                                                 '0'
         59        SEND_VAL                                                 '0'
         60        SEND_VAL                                                 '0'
         61        SEND_VAR                                                 !2
         62        SUB                                              ~30     !1, !5
         63        SEND_VAL                                                 ~30
         64        SEND_VAR                                                 !3
         65        DO_ICALL                                         $31     
         66        ASSIGN                                                   !6, $31
   22    67        ASSIGN                                                   !7, 86400
   25    68        ASSIGN                                                   !8, 0
         69      > JMP                                                      ->79
   27    70    >   INIT_FCALL                                               'date'
         71        SEND_VAL                                                 'Y-m-d'
         72        MUL                                              ~36     !7, !8
         73        ADD                                              ~37     !6, ~36
         74        SEND_VAL                                                 ~37
         75        DO_ICALL                                         $38     
         76        ASSIGN_DIM                                               !9, !8
         77        OP_DATA                                                  $38
   25    78        PRE_INC                                                  !8
         79    >   IS_SMALLER                                               !8, 7
         80      > JMPNZ                                                    ~40, ->70
   30    81    > > RETURN                                                   !9
   31    82*     > RETURN                                                   null

End of function week_from_monday

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.38 ms | 1404 KiB | 19 Q