I'm trying to output an array containing events which is ical file output to be precise. Array in itself looks as below:
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
) )
I'm able to loop trough its records and output all events using the following foreach loop:
foreach ($events_sorted as $event) {
$client = current(explode("_", $event['SUMMARY']));
} and so on...
The tricky part is that my table layout for events is based on months and looks as follows:
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
What I'm unable to do is to loop trough all the events, output their corresponding month name once as per layout, output their data for the corresponding events and proceed to the next month.
My table layout however is built the way that its its first row contains month name data and has to be somehow distinguished from all other rows containing events:
<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>
Until now I also tried creating new array based on months but with no luck either:
foreach($events_sorted as $test) {
$month_number = gmdate("m", $ical->iCalDateToUnixTimestamp($test['DTSTART']));
$r = array("month" => $month_number);
}
My last idea was to print out all events and by resetting array check for existence of month name, if it exists then do not output it again and use different table row layout but I'm unsure how to implement this solution. I hope there is easier way to achieve described effect