How to create news feeds. (part II)
With the codes posted on the first part of the news feeds tutorial, assuming that the codes were posted to the correct forms, you should now have a storage file system where you can dump all the articles you have and you are now able to post it. But of course, what is the sense of a news display if people can’t see it? So there should be a page where your news can be flashed and displayed. To do this, the index.php page you have created will come into use. You have to use the “opendir” and “readdir” commands so that your news files will be arranged in a chronological order. You then have to put these codes:
function getNewsList(){
$fileList = array();
// Open the actual directory
if ($handle = opendir(“news”)) {
// Read all file from the actual directory
while ($file = readdir($handle)) {
if (!is_dir($file)) {
$fileList[] = $file;
}
}
}
rsort($fileList);
return $fileList;
}
?>
Photo taken from http://news.dmusic.com
