0

正確には、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

私ができないことは、すべてのイベントをループし、対応する月の名前をレイアウトごとに 1回出力し、対応するイベントのデータを出力して、次の月に進むことです。

ただし、私のテーブル レイアウトは、最初の行に月名データが含まれ、イベントを含む他のすべての行と何らかの方法で区別する必要があるように構築されています。

<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);

}

私の最後のアイデアは、すべてのイベントを出力し、月名の存在の配列チェックをリセットすることでした。存在する場合は、再度出力せずに別のテーブル行レイアウトを使用することでしたが、このソリューションを実装する方法がわかりません。説明された効果を達成するためのより簡単な方法があることを願っています

4

1 に答える 1

1
<table>
    <tr>
      <td width="20%"></td>
      <td>CLIENT</td>
      <td>EXHIBITION</td>
      <td>CITY</td>
    </tr>
    <?php $last_event = NULL; ?>
    <?php foreach($events as $event) : ?>
    <tr>
      <td><?php if($last_event != NULL) : if($last_event['DATE'] != $event['DATE']) : echo $event['DATE']; endif; else : echo $event['DATE']; endif; ?></td>
      <td><?php echo $event['CLIENT']; ?></td>
      <td><?php echo $event['EXHIBITION']; ?></td>
      <td><?php echo $event['CITY']; ?></td>
    </tr>
    <?php $last_event = $event; ?>
    <?php endforeach; ?>
  </table>

$last_eventを通過したすべてのイベントを保持する変数がありますforeach。行の現在のイベントと同じ日付を持ってifいるかどうかを判断するループ内のステートメントがあります。$last_eventはいの場合は日付を印刷せずに合格し、そうでない場合は日付を印刷します。ループが終了する前に、$last_event現在通過したイベントを次の決定に割り当てる割り当てがあります。これは、私が説明できる最も単純な形式です。

さて、印刷するだけで似たような日付を推測したくない場合は、別のシナリオです。

于 2013-11-13T22:40:09.873 に答える