3v4l.org

run code in 300+ PHP versions simultaneously
<?php const WEEK_YEAR_FORMAT = 'o-W'; function subtract_weeks_from_iso_week( string $start, int $weeks ): string { // Inputs are guaranteed (per usage) to be in 'o-W' => 'YYYY-WW' format. [ $start_year, $start_week ] = array_map( 'intval', explode( '-', $start ) ); $start_date = ( new DateTimeImmutable() )->setISODate( $start_year, $start_week ); $result_date = $start_date->modify( '-' . $weeks . ' weeks' ); return $result_date->format( WEEK_YEAR_FORMAT ); } echo subtract_weeks_from_iso_week("2026-10", 4);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0bjrD
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'WEEK_YEAR_FORMAT', 'o-W'
   12     1        INIT_FCALL                                               'subtract_weeks_from_iso_week'
          2        SEND_VAL                                                 '2026-10'
          3        SEND_VAL                                                 4
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
          6      > RETURN                                                   1

Function subtract_weeks_from_iso_week:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0bjrD
function name:  subtract_weeks_from_iso_week
number of ops:  36
compiled vars:  !0 = $start, !1 = $weeks, !2 = $start_year, !3 = $start_week, !4 = $start_date, !5 = $result_date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 'intval'
          4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '-'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                         $7      
         10        FETCH_LIST_R                                     $8      $7, 0
         11        ASSIGN                                                   !2, $8
         12        FETCH_LIST_R                                     $10     $7, 1
         13        ASSIGN                                                   !3, $10
         14        FREE                                                     $7
    7    15        NEW                                              $12     'DateTimeImmutable'
         16        DO_FCALL                                      0          
         17        INIT_METHOD_CALL                                         $12, 'setISODate'
         18        SEND_VAR_EX                                              !2
         19        SEND_VAR_EX                                              !3
         20        DO_FCALL                                      0  $14     
         21        ASSIGN                                                   !4, $14
    8    22        INIT_METHOD_CALL                                         !4, 'modify'
         23        CONCAT                                           ~16     '-', !1
         24        CONCAT                                           ~17     ~16, '+weeks'
         25        SEND_VAL_EX                                              ~17
         26        DO_FCALL                                      0  $18     
         27        ASSIGN                                                   !5, $18
    9    28        INIT_METHOD_CALL                                         !5, 'format'
         29        FETCH_CONSTANT                                   ~20     'WEEK_YEAR_FORMAT'
         30        SEND_VAL_EX                                              ~20
         31        DO_FCALL                                      0  $21     
         32        VERIFY_RETURN_TYPE                                       $21
         33      > RETURN                                                   $21
   10    34*       VERIFY_RETURN_TYPE                                       
         35*     > RETURN                                                   null

End of function subtract_weeks_from_iso_week

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.86 ms | 1024 KiB | 16 Q