我正在尝试输出一个包含事件的数组,准确地说是 ical 文件输出。数组本身如下所示:
Array (
[0] => Array (
[UID] => 4C2DDB6E-5B5B-4B97-BEBE-FF424BB154F8
[DTEND] => 20131116 [SUMMARY] => test1_ONS
[LAST-MODIFIED] => 20131111T210530Z
[DTSTAMP] => 20131111T213437Z
[DTSTART] => 20131112
[LOCATION] => City
[SEQUENCE] => 1
[DESCRIPTION] => description here_http://www.test.com/test1
[SUMMARY] => some text here
) )
我可以使用以下 foreach 循环遍历其记录并输出所有事件:
foreach ($events_sorted as $event) {
$client = current(explode("_", $event['SUMMARY']));
} and so on...
棘手的部分是我的事件表布局基于月份,如下所示:
CLIENT EXHIBITION CITY
_________________________________________
OCT 2013 client exhibition city
client exhibition city
client exhibition city
________________________________________
NOV 2013 client exhibition city
client exhibition city
________________________________________
DEC 2013 client exhibition city
我无法做的是循环遍历所有事件,根据布局输出一次相应的月份名称,输出相应事件的数据并继续下个月。
然而,我的表格布局是按照其第一行包含月份名称数据的方式构建的,并且必须以某种方式与包含事件的所有其他行区分开来:
<table id="table_events">
<tbody><tr id="header_row">
<th id="date_header"></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr class="month_start">
<td>
<div class="month_rect">
<div class="month_rect_text month_long">SEPT</div>
<div class="month_rect_year">2013</div>
</div>
</td>
<td>eee</td>
<td>eee</td>
<td>Oslo</td>
</tr>
<tr>
<td>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td></td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr id="oct" class="month_start">
<td>
<div class="month_rect">
<div class="month_rect_text month_short">OCT</div>
<div class="month_rect_year">2013</div>
</div>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr class="month_start">
<td>
<div class="month_rect">
<div class="month_rect_text month_short">NOV</div>
<div class="month_rect_year">2013</div>
</div>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>
</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
</tbody></table>
到目前为止,我还尝试根据月份创建新数组,但也没有运气:
foreach($events_sorted as $test) {
$month_number = gmdate("m", $ical->iCalDateToUnixTimestamp($test['DTSTART']));
$r = array("month" => $month_number);
}
我的最后一个想法是打印出所有事件并通过重置数组检查是否存在月份名称,如果存在则不要再次输出它并使用不同的表格行布局,但我不确定如何实现这个解决方案。我希望有更简单的方法来实现描述的效果