3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
44.43 ms | 402 KiB | 5 Q