我希望本周的学生和事件以日历格式显示。每个学生从星期一到星期天有7个数组,每个数组的内部数组有一天的事件
$array = [
'Alex' => [
[
['event' => 'eventName1'],['event' => 'eventName2']
],
[
['event' => 'eventName3'],['event' => 'eventName4']
],
[
['event' => 'eventName5'],['event' => 'eventName6']
],
[
['event' => 'eventName7'],['event' => 'eventName8']
],
[],
[],
[]
],
'Allen' => [
[
['event' => 'eventName'],['event' => 'eventName']
],[
['event' => 'eventName'],['event' => 'eventName']
],
[],
[],
[],
[],
[]
],
];
我需要数组显示为周日历,我不知道下面的代码哪里出错了
<table>
<thead>
<tr>
<th>Participant</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thrusday</th>
<th>Friday</th>
<th>Satday</th>
<th>Sunday</th>
</tr>
</thead>
<tbody>
<?php foreach ($array as $participant => $event): ?>
<?php foreach ($event as $i => $value):?>
<tr>
<?php if ($i === 0): ?>
<td rowspan="2"><?= $participant ?></td>
<?php endif ?>
<?php foreach ($value as $index => $eventD):?>
<td><?php echo $eventD['event']; ?></td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
<?php endforeach ?>
</tbody>
</table>
我的问题是循环以及如何打印特定日期的事件。任何人都可以在建立正确的格式。谢谢你的帮助
3条答案
按热度按时间czq61nw11#
如果我的理解是正确的,就这样试试
小提琴连杆http://sandbox.onlinephpfunctions.com/
chy5wohz2#
检查此html
webghufk3#