料青山看我应如是
试试这个代码,如果我理解正确的话))<?$startDay = '2019-09-25';$aSchedule = array(1,2,4);$iCntShed = count($aSchedule);$iLessonsCnt = 8;$iDWStartDay = date('w',strtotime($startDay));$aDOWMap = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');// first day according Schedule array and startDay$aWeekDays = array_filter($aSchedule,function($iSDW) use ($iDWStartDay){ return $iSDW>= $iDWStartDay;});// day according of week$nextDate = date('Y-m-d',strtotime($startDay.' next '.$aDOWMap[end($aWeekDays)]));$i = 0;while (count($aWeekDays)<$iLessonsCnt) { $i = $i<$iCntShed ? $i : 0; $aWeekDays[] = $aSchedule[$i]; $nextDate = date('Y-m-d',strtotime($nextDate.' next '.$aDOWMap[$aSchedule[$i++]]));}print_r($aWeekDays);echo $nextDate;