我目前对一种非常奇怪的行为感到失望,这种行为对我来说非常奇怪,即将php值回送到html表格单元格。
我只想循环遍历一个数组并将值打印到一个表中,但在特殊条件下只显示一些信息。
表外显示了这些值。
<?php
foreach ($mpbs_overview_tab4_bookings as $tab4_arr) {
echo "<tr>";
$tab4startDate = new DateTime($tab4_arr->starttime);
$tab4endDate = new DateTime($tab4_arr->endtime);
echo \'<td>\' . $tab4startDate->format(\'d.m.Y H:i\') .\'</td>\';
echo \'<td>\' . $tab4endDate->format(\'d.m.Y\') .\'</td>\';
echo \'<td>\' . $tab4_arr->username .\'</td>\';
echo "</tr>";
}
?>
使用此代码,
$tab4startDate->format(\'d.m.Y H:i\')
如图所示,
$tab4endDate->format(\'d.m.Y\')
不正在添加
H:i
到
$tab4endDate
s格式的结果是,它会再次显示。
$tab4_arr->username
也未显示。如果我将内容更改为
echo "<td>";
echo $tab4startDate->format(\'d.m.Y H:i\');
echo $tab4_arr->username;
echo "</td>";
出于测试目的,用户名也是可见的。。。
有人知道我做错了什么吗?
这是我的阵列:
{"id":"185","starttime":"2017-11-26 00:00:00","endtime":"2017-11-29 00:00:00","username":"lsgit"},
{"id":"186","starttime":"2017-11-26 00:00:00","endtime":"2017-11-29 00:00:00","username":"lsgit"},
{"id":"187","starttime":"2017-11-19 00:00:00","endtime":"2017-11-22 00:00:00","username":"lsgit"},
{"id":"188","starttime":"2017-11-30 00:00:00","endtime":"2017-12-03 00:00:00","username":"lsgit"},
{"id":"189","starttime":"2017-12-05 00:00:00","endtime":"2017-12-08 00:00:00","username":"lsgit"},
{"id":"190","starttime":"2017-12-05 00:00:00","endtime":"2017-12-08 00:00:00","username":"lsgit"},
{"id":"191","starttime":"2017-12-05 00:00:00","endtime":"2017-12-08 00:00:00","username":"lsgit"}