Reputation: 4296
$datetime = new \DateTime();
$listItem = array('<li">', '</li>');
$listItem_active = array('<li class="active-day">', '</li>');
$i = 0;
while (true) {
if ($i === 5) break;
if ($datetime->format('N') === '7' && $i === 0) {
$datetime->add(new \DateInterval('P1D'));
continue;
}
if($i===0){
$today = $datetime->format('D d-m');
}
if($i===3){
echo $listItem_active[0] . $today . $listItem_active[1];
}
if($i!=0){
echo $listItem[0] . $datetime->format('D d-m') . $listItem[1];
}
$listItem = array('<li>', '</li>');
$datetime->add(new \DateInterval('P1D'));
$i++;
}
I have the above code made and its almost right, but the output is not exactly how i want it. I get the following output:
The current day should always be in the middle. as you can see this works. but the order of the days is not as i desire. The order i desire is this :
Upvotes: 1
Views: 59