Jump to content

[SOLVED] Splitting up Dates


JSHINER

Recommended Posts

I have the following:

 

foreach ($page['events'] as $z) {

echo '<b>', $z['date'], '</b> - ', '<a href="', $z['link'], '">', htmlentities($z['title']), '</a>  </br>', htmlentities(stripslashes($z['description'])), '</p>';

}

 

Which displays: 2007-03-23 - Title... 2007-03-23 - Title 2.... 2007-03-24 - Title ... etc... But I want it to display as:

 

2007-03-23

 

2007-03-23 - Title

 

2007-03-23 - Title 2

 

2007-03-24

 

2007-03-24 Title

Link to comment
https://forums.phpfreaks.com/topic/43978-solved-splitting-up-dates/
Share on other sites

No I think he wanted to viel all events of one day.

Try that one:

<?php
   foreach ($page['events'] as $a) {
      if (!isset($events[$a['date']])) $events[$a['date']] = array();
      $events[$a['date']][] = $a;
   }

   foreach ($events as $i => $a) {
      echo "<b>$i</b><br />\n";
      foreach ($a as $z) {
         echo '<b>', $z['date'], '</b> - ', '<a href="', $z['link'], '">', htmlentities($z['title']), '</a>  </br>', htmlentities(stripslashes($z['description'])), '</p>';
      }
   }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.