$startDate = 20130201;
$date = 20130505;
$aDates = $this->getDates($startDate, $date);
public function getDates($startDate, $date) {
$tmpStartDate = date("Ymd", strtotime($startDate.'+1 Day'));
$tmpEndDate = date("Ymd", strtotime($tmpStartDate.'+1 Month'));
if($date >= $tmpStartDate && $date <= $tmpEndDate) {
//return array('startDate' => $tmpStartDate, 'endDate' => $tmpEndDate);
} else {
$this->getDates($tmpEndDate, $date);
}
}
答案 0 :(得分:8)
如果调用了} else {,则递归调用不会返回任何内容。
尝试取消注释您的注释行并将“return”添加到该else子句的开头:
return $this->getDates($tmpEndDate, $date);