【发布时间】:2012-11-29 20:22:47
【问题描述】:
如何用循环编写这段代码?
$date = new DateTime;
if(checkForDate($date->format('m')) == true) {
return true;
}
else {
$date->sub(new DateInterval('P1M'));
if(checkForDate($date->format('m')) == true) {
return true;
}
else {
$date->sub(new DateInterval('P1M'));
if(checkForDate($date->format('m')) == true) {
return true;
}
else {
// Fail.
return false;
}
}
}
【问题讨论】:
标签: php function loops while-loop