So I came up with this, which is a news script. The files has names with [27.11.13] A breaking news! as dates, and rsort will sort them all reversed to keep the latest one up. BUT, the question is, how can i also make the last one (which is the newest) have a bold tag? (I actually want to add some effects to it, so making it bold is just an example and i just need the directions)
<?php
$files = array();
if($handle = opendir( 'includes/news' )) {
while( $file = readdir( $handle )) {
if ($file != '.' && $file != '..') {
// let's check for txt extension
$extension = substr($file, -3);
// filename without '.txt'
$filename = substr($file, 0, -4);
if ($extension == 'txt')
$files[] = $filename; // or $filename
}
}
closedir($handle);
}
rsort($files);
foreach ($files as $file)
echo '<h2><a href="?module=news&read=' . $file
. '">» ' . $file . "</a></h2>";
}
?>