【发布时间】:2018-06-11 09:19:23
【问题描述】:
我正在尝试创建一个日历系统,该系统将显示在某些日子预订了哪些工作,我希望它是一个水平日历,将月份的所有日期作为表格行和一周中的几天作为下一行。我已经对第一行进行了排序,但我需要让第二行重复一周中的几天的数组,直到月末。
//Establish How many days are in the current Month
$currentMonthDays = date("t");
$daysOfWeek = array('M','T','W','T','F','Sa','Su');
echo '<table cellpadding="0" cellspacing="0" border="1" bordercolor="ffffff">
<tr>';
for ($i = 1; $i <= $currentMonthDays; $i++)
{
echo '<td width="30" align="center">'.$i.'</td>';
}
echo '</tr><tr>';
foreach($daysOfWeek as $day){
echo '<td width="30" align="center">'.$day.'</td>';
}
echo '</tr>';
【问题讨论】:
标签: php arrays loops for-loop calendar