*/ while ($row = mysql_fetch_array($result)) { $date = date_parse($row['post_date']); $row_year = $date['year']; $row_month = $date['month']; $row_day = $date['day']; // $year stores the index of the current year $year = $timeline->findYear($row_year); if ($year == -1) { // year does not exist, create the year $timeline->addYear($row_year); // re-index $year = $timeline->findYear($row_year); } // $month stores the index of the current month $month = $timeline->getYear($year)->findMonth($row_month); if ($month = -1) { // month does not exist, create the month $timeline->getYear($year)->addMonth($row_month); // re-index $month = $timeline->getYear($year)->findMonth($row_month); } $timeline->getYear($year)->getMonth($month)->addPost($row_day, $row['post_title'], $row['ID']); } echo $timeline->toString(); class Timeline { var $years = array(); var $count = 0; function findYear($year_number) {