Thursday, 8 August 2013

While statement infinite looping

While statement infinite looping

I can't for the life of me figure out why this function is in an infinite
loop. It's probably something simple I'm just not seeing. It is given the
year, then it prints out every month from 7/[start-year] until this month.
function showmonths($year) {
$start = strtotime($year.'-07-01');
$end = strtotime("now");
while($end >= $start) {
$months[] = strtotime("-1 month", $end);
$end = strtotime("-1 month", $end);
}
return $months;
}

No comments:

Post a Comment