3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $year = '2015'; $week = '01'; $month = date('m', strtotime($year . 'W' . $week)); $weeks = [ '0' => ((int)$week == 1) ? date('W', strtotime('December 28th,' . $year - 1)) : (int)$week - 1, '1' => $week, '2' => (date('W', strtotime('December 28th,' . $year)) == $week) ? '01' : (int)$week + 1, '3' => (date('W', strtotime('December 28th,' . $year)) == $week) ? '01' : (int)$week + 2, '4' => (date('W', strtotime('December 28th,' . $year)) == $week) ? '01' : (int)$week + 3, '5' => (date('W', strtotime('December 28th,' . $year)) == $week) ? '01' : (int)$week + 4 ]; print_r($weeks);
based on 0BLUm
Output for 7.1.0 - 7.2.0
Warning: A non-numeric value encountered in /in/ZRGqD on line 7 Array ( [0] => 40 [1] => 01 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )
Output for 5.4.0 - 7.0.20
Array ( [0] => 40 [1] => 01 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )