3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ISOdates_from_weeknr ($weeknr, $year, $format = '%d-%m-%Y') { $start = strtotime ('1 january ' . $year); $week1 = strftime ('%V', $start); while ($week1 != '01') { $start += (7 * 24 * 3600); $week1 = strftime ('%V', $start); } $timestamp_week = strtotime ('+' . ($weeknr - 1) . ' week', $start); $weekdag = strftime ('%u', $timestamp_week); $dagen_tot_begin_week = $weekdag - 1; $dagen_tot_eind_week = 7 - $weekdag; $checkdatum = strtotime ("-" . $dagen_tot_begin_week . " days + 3 days", $timestamp_week); $check = strftime ('%V', $checkdatum); if ($check == '01' && $weeknr > 52) { echo 'ongeldig weeknummer voor dit jaar' . "\n"; return false; } $begindatum = strtotime ("-" . $dagen_tot_begin_week . " days", $timestamp_week); $einddatum = strtotime ("+" . $dagen_tot_eind_week . " days", $timestamp_week); return array (strftime ($format, $begindatum), strftime ($format, $einddatum)); } echo "Output for 5.4.11 - 7.0.2, 7.1@2015-11, hhvm-3.6.1 - 3.11.0".PHP_EOL; echo ISOdates_from_weeknr(1, 2016)[0].PHP_EOL; echo ISOdates_from_weeknr(1, 2016)[1]; echo "Andere PHP die oud is".PHP_EOL; $date = ISOdates_from_weeknr(1, 2016); echo $date[0].PHP_EOL; echo $date[1].PHP_EOL; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e7hH4
function name:  (null)
number of ops:  27
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ECHO                                                     'Output+for+5.4.11+-+7.0.2%2C+7.1%402015-11%2C+hhvm-3.6.1+-+3.11.0%0A'
   24     1        INIT_FCALL                                               'isodates_from_weeknr'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 2016
          4        DO_FCALL                                      0  $1      
          5        FETCH_DIM_R                                      ~2      $1, 0
          6        CONCAT                                           ~3      ~2, '%0A'
          7        ECHO                                                     ~3
   25     8        INIT_FCALL                                               'isodates_from_weeknr'
          9        SEND_VAL                                                 1
         10        SEND_VAL                                                 2016
         11        DO_FCALL                                      0  $4      
         12        FETCH_DIM_R                                      ~5      $4, 1
         13        ECHO                                                     ~5
   28    14        ECHO                                                     'Andere+PHP+die+oud+is%0A'
   29    15        INIT_FCALL                                               'isodates_from_weeknr'
         16        SEND_VAL                                                 1
         17        SEND_VAL                                                 2016
         18        DO_FCALL                                      0  $6      
         19        ASSIGN                                                   !0, $6
   30    20        FETCH_DIM_R                                      ~8      !0, 0
         21        CONCAT                                           ~9      ~8, '%0A'
         22        ECHO                                                     ~9
   31    23        FETCH_DIM_R                                      ~10     !0, 1
         24        CONCAT                                           ~11     ~10, '%0A'
         25        ECHO                                                     ~11
   33    26      > RETURN                                                   1

Function isodates_from_weeknr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 14
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 53, Position 2 = 55
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 14
Branch analysis from position: 22
Branch analysis from position: 14
filename:       /in/e7hH4
function name:  ISOdates_from_weeknr
number of ops:  84
compiled vars:  !0 = $weeknr, !1 = $year, !2 = $format, !3 = $start, !4 = $week1, !5 = $timestamp_week, !6 = $weekdag, !7 = $dagen_tot_begin_week, !8 = $dagen_tot_eind_week, !9 = $checkdatum, !10 = $check, !11 = $begindatum, !12 = $einddatum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      '%25d-%25m-%25Y'
    3     3        INIT_FCALL                                               'strtotime'
          4        CONCAT                                           ~13     '1+january+', !1
          5        SEND_VAL                                                 ~13
          6        DO_ICALL                                         $14     
          7        ASSIGN                                                   !3, $14
    4     8        INIT_FCALL                                               'strftime'
          9        SEND_VAL                                                 '%25V'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $16     
         12        ASSIGN                                                   !4, $16
    5    13      > JMP                                                      ->20
    6    14    >   ASSIGN_OP                                     1          !3, 604800
    7    15        INIT_FCALL                                               'strftime'
         16        SEND_VAL                                                 '%25V'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $19     
         19        ASSIGN                                                   !4, $19
    5    20    >   IS_NOT_EQUAL                                             !4, '01'
         21      > JMPNZ                                                    ~21, ->14
    9    22    >   INIT_FCALL                                               'strtotime'
         23        SUB                                              ~22     !0, 1
         24        CONCAT                                           ~23     '%2B', ~22
         25        CONCAT                                           ~24     ~23, '+week'
         26        SEND_VAL                                                 ~24
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                         $25     
         29        ASSIGN                                                   !5, $25
   10    30        INIT_FCALL                                               'strftime'
         31        SEND_VAL                                                 '%25u'
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                         $27     
         34        ASSIGN                                                   !6, $27
   11    35        SUB                                              ~29     !6, 1
         36        ASSIGN                                                   !7, ~29
   12    37        SUB                                              ~31     7, !6
         38        ASSIGN                                                   !8, ~31
   13    39        INIT_FCALL                                               'strtotime'
         40        CONCAT                                           ~33     '-', !7
         41        CONCAT                                           ~34     ~33, '+days+%2B+3+days'
         42        SEND_VAL                                                 ~34
         43        SEND_VAR                                                 !5
         44        DO_ICALL                                         $35     
         45        ASSIGN                                                   !9, $35
   14    46        INIT_FCALL                                               'strftime'
         47        SEND_VAL                                                 '%25V'
         48        SEND_VAR                                                 !9
         49        DO_ICALL                                         $37     
         50        ASSIGN                                                   !10, $37
   15    51        IS_EQUAL                                         ~39     !10, '01'
         52      > JMPZ_EX                                          ~39     ~39, ->55
         53    >   IS_SMALLER                                       ~40     52, !0
         54        BOOL                                             ~39     ~40
         55    > > JMPZ                                                     ~39, ->58
   16    56    >   ECHO                                                     'ongeldig+weeknummer+voor+dit+jaar%0A'
   17    57      > RETURN                                                   <false>
   19    58    >   INIT_FCALL                                               'strtotime'
         59        CONCAT                                           ~41     '-', !7
         60        CONCAT                                           ~42     ~41, '+days'
         61        SEND_VAL                                                 ~42
         62        SEND_VAR                                                 !5
         63        DO_ICALL                                         $43     
         64        ASSIGN                                                   !11, $43
   20    65        INIT_FCALL                                               'strtotime'
         66        CONCAT                                           ~45     '%2B', !8
         67        CONCAT                                           ~46     ~45, '+days'
         68        SEND_VAL                                                 ~46
         69        SEND_VAR                                                 !5
         70        DO_ICALL                                         $47     
         71        ASSIGN                                                   !12, $47
   21    72        INIT_FCALL                                               'strftime'
         73        SEND_VAR                                                 !2
         74        SEND_VAR                                                 !11
         75        DO_ICALL                                         $49     
         76        INIT_ARRAY                                       ~50     $49
         77        INIT_FCALL                                               'strftime'
         78        SEND_VAR                                                 !2
         79        SEND_VAR                                                 !12
         80        DO_ICALL                                         $51     
         81        ADD_ARRAY_ELEMENT                                ~50     $51
         82      > RETURN                                                   ~50
   22    83*     > RETURN                                                   null

End of function isodates_from_weeknr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.59 ms | 1407 KiB | 20 Q