3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startDateTime = new DateTime('2016-10-17'); $currentDate = new DateTime('2017-2-5'); $startDateTime->modify('+1 day'); $currentWeekNumber = $currentDate->format('W') + (($currentDate->format('o') - $startDateTime->format('o')) * 52); //Subtract the start week from the current week (and add 1, since we start at Week 1) to find the current study week echo $currentWeekNumber - $startDateTime->format('W') + 1;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dKPrY
function name:  (null)
number of ops:  31
compiled vars:  !0 = $startDateTime, !1 = $currentDate, !2 = $currentWeekNumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'DateTime'
          1        SEND_VAL_EX                                              '2016-10-17'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
    4     4        NEW                                              $6      'DateTime'
          5        SEND_VAL_EX                                              '2017-2-5'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
    6     8        INIT_METHOD_CALL                                         !0, 'modify'
          9        SEND_VAL_EX                                              '%2B1+day'
         10        DO_FCALL                                      0          
    7    11        INIT_METHOD_CALL                                         !1, 'format'
         12        SEND_VAL_EX                                              'W'
         13        DO_FCALL                                      0  $10     
         14        INIT_METHOD_CALL                                         !1, 'format'
         15        SEND_VAL_EX                                              'o'
         16        DO_FCALL                                      0  $11     
         17        INIT_METHOD_CALL                                         !0, 'format'
         18        SEND_VAL_EX                                              'o'
         19        DO_FCALL                                      0  $12     
         20        SUB                                              ~13     $11, $12
         21        MUL                                              ~14     ~13, 52
         22        ADD                                              ~15     $10, ~14
         23        ASSIGN                                                   !2, ~15
   10    24        INIT_METHOD_CALL                                         !0, 'format'
         25        SEND_VAL_EX                                              'W'
         26        DO_FCALL                                      0  $17     
         27        SUB                                              ~18     !2, $17
         28        ADD                                              ~19     ~18, 1
         29        ECHO                                                     ~19
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.78 ms | 1394 KiB | 13 Q