I have two pieces of information extracted from a MySQL database, the year(2009, 2010, ect) and the week (1-52). And I need to convert it i
Since this question and the accepted answer were posted the DateTime classes make this much simpler to do:-
function daysInWeek($weekNum)
{
$result = array();
$datetime = new DateTime();
$datetime->setISODate((int)$datetime->format('o'), $weekNum, 1);
$interval = new DateInterval('P1D');
$week = new DatePeriod($datetime, $interval, 6);
foreach($week as $day){
$result[] = $day->format('d/m/Y');
}
return $result;
}
var_dump(daysInWeek(24));
Output:-
array (size=7)
0 => string '10/06/2013' (length=10)
1 => string '11/06/2013' (length=10)
2 => string '12/06/2013' (length=10)
3 => string '13/06/2013' (length=10)
4 => string '14/06/2013' (length=10)
5 => string '15/06/2013' (length=10)
6 => string '16/06/2013' (length=10)
This has the added advantage of taking care of leap years etc..