@ 2015-10-02T11:02:37Z <?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);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Array
(
[0] => 52
[1] => 01
[2] => 2
[3] => 3
[4] => 4
[5] => 5
)
Output for 7.4.0 - 7.4.33 Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/ZRGqD on line 7
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 7.1.0 - 7.1.20 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 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 - 5.4.45 , 5.5.0 - 5.5.37 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 Array
(
[0] => 40
[1] => 01
[2] => 2
[3] => 3
[4] => 4
[5] => 5
)
preferences:dark mode live preview
210.6 ms | 402 KiB | 266 Q