// 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) { for ($i = 0; $i < count($this->years); $i++) { if ($this->years[$i]->getNumber() == $year_number) { return $i; } } return -1; } function addYear($year_number) {