I am currently working on a news posting script for my team's site using PHP. I've got everything down for posting and adding news, but I need a way to have only the most recent posts added. I tried to create a while loop so that only the 5 most recent posts show on the index page, but it didn't work. If anyone can help me figure it out, help would be greatly appreciated. And i simplified the part of the code that displays the post.
PHP Code:
<?
$data = file('news.txt');
$data = array_reverse($data);
foreach($data as $element) {
$element = trim($element);
$pieces = explode("|", $element);
echo $pieces[0] . $pieces[1] . "\n";
echo "<hr>\n";
}
?>
__________________
2005 Las Vegas Regional Autodesk Visualization Award
2005 Las Vegas Regional #8 Seeded Alliance with 988 and 1505
2006 Southern California Regional #15 seed