Bloggings

isDir() && !$dirinfo->isDot()) { $years[] = $dirinfo->getFilename(); } } rsort($years); // iterate through years if (is_array($years)) { foreach ($years as $key => $year) { $items = []; $thisdir = new DirectoryIterator("./articles/" . $year); // iterate through files foreach ($thisdir as $file) { if (!$file->isDot()) { $flag = ""; $articledate = date("Y-m-d"); $filemodified = date( "Y-m-d", filemtime("./articles/" . $year . "/" . $file), ); $content = file_get_contents($file->getPathname()); # get first h3 preg_match("/

(.*?)<\/h3>/s", $content, $date); if (isset($date[1]) && strtotime($date[1])) { $articledate = date("Y-m-d", strtotime($date[1])); } if ( $articledate >= date("Y-m-d", strtotime(date("Y-m-d") . " - 2 days")) ) { $flag = " New"; } preg_match("/

(.*?)<\/h2>/s", $content, $titre); $title = "?"; if (isset($titre[1])) { $title = ucfirst($titre[1]); } $items[] = '\n"; } } rsort($items); echo "
\n"; echo "

" . $year . "

\n"; foreach ($items as $key => $val) { if ($key == 0) { if ($year == date("Y")) { preg_match("'href=\"(.*?)\"'si", $val, $match); if ($match) { $content = file_get_contents($match[1], false, null, 1); preg_match( "'\(.*?)<\/article\>'si", $content, $article, ); if ($article) { # print latest article contents echo $article[1] . "\n

\n"; } } } echo "
    \n"; } # print link to article echo $val; } echo "
\n"; echo "
\n"; } } else { echo "Not an array"; } ?>