我在从复杂循环中填充表时遇到问题。
该表由 7 天日历表组成,每天应包含其下的日事件。
Array
(
[2012-12-16] => Array
(
)
[2012-12-17] => Array
(
[0] => Array
(
[date] => 2012-12-17
[time_booked] => 00:09:00
[time_start] => 00:00:00
[time_end] => 00:00:00
[name] => maha mostafa elrashed
[first_name] => marwan
[title] => root cannal
)
[1] => Array
(
[date] => 2012-12-17
[time_booked] => 09:00:00
[time_start] => 00:00:00
[time_end] => 00:00:00
[name] => demo demo eldemo
[first_name] => marwan
[title] => ultrasound
)
)
[2012-12-18] => Array
(
[0] => Array
(
[date] => 2012-12-18
[time_booked] => 09:00:00
[time_start] => 00:00:00
[time_end] => 00:00:00
[name] => demo demo eldemo
[first_name] => marwan
[title] => root cannal
)
)
[2012-12-19] => Array
(
)
[2012-12-20] => Array
(
)
[2012-12-21] => Array
(
)
[2012-12-22] => Array
(
)
)
我想将这个数组示例转换为表格。目前我发现最简单的方法是将每天打印为 ul 并浮动离开它们,但我真正想要的是用它们制作一个表格,以便将来能够使用 jQuery 对该表格进行排序。
foreach($ztable as $t){
echo"\n<ul style='float:left;width:140px'>";
foreach($t as $r){
echo "<li class='{$r['first_name']}'>{$r['name']}</li>";
}
echo "</ul>\n";
}
有什么建议么?顺便说一句,我正在使用 Codeigniter 2
编辑:
上表来自建议的答案,下一张是我想要的。