PHP 表示下个月日期


php foreach next month dates

我需要的是下个月列出,每个新天都在新行上列出。其实我接下来想看看:

date     | username1 | username2
_________|___________|__________
         |           |
Mon - 01 | user5     | user2
         |           |
Tue - 02 | user3     | user2
....
and so on

稍后我将收集这些日期和用户名并更新sql表(相同类型,如此处的示例)。

我有这个代码:

$workdays = array();
$type = CAL_GREGORIAN;
$month = date('n'); // Month ID, 1 through to 12.
$year = date('Y'); // Year in 4 digit 2009 format.
$day_count = cal_days_in_month($type, $month, $year); // Get the amount of days
//loop through all days
for ($i = 1; $i <= $day_count; $i++) {
$date = $year.'-'.$month.'-'.$i; //format date
$workdays[] = $i;

有了 Foreach Echo,我得到了第 1、2、3 天......等等正确,每个人都在新行上。但是,如果我把这个放在里面:

<?php foreach($workdays as $value['date']): ?>
<tr>
<td><?php if ($value['date'] != 'dd'){
    setlocale(LC_TIME, 'fi_FI.UTF-8');
    echo ucfirst(strftime("%a - %d", strtotime($value['date'])));
    } else {
    echo 'wrong';
    }?></td>
<td>&nbsp;</td>
</tr>
<?php endforeach ?>

我上了周一 - 01 的每一条新线。

出了什么问题(在那之后,我在 php 上新手)?

尝试这样的事情。

<?php
$day_count = date('t',strtotime('+1 month'));
$month = date('m');
$year = date('Y');
if ($month == 12) { $month = 1; $year++; }
for($i = 1; $i<=$day_count; $i++) {
  echo '<tr>';
  echo '<td>'.date('D',strtotime("$month/$i/$year")).' '.$i."</td>";
  echo '<td>&nbsp;</td>';
  echo '</tr>';
}