Sort by Last Updated (PLEASE, I'm so close!)
Posted: Mon Oct 10, 2005 8:21 pm
I just want these thumbnails to sort by the most recently uploaded. How do I do that?
Can I just change the "sort($photos);" line somehow?
Code: Select all
<?php
$fileregex = "[gif]"; // Specify only .gif files
$all = opendir('non-music/'); // Define image folder
$photos = array(); // Define array
// Fill the array:
while ($file = readdir($all)) {
if (!is_dir($location.'/'.$file) and $file != ".." and $file != ".") {
if (preg_match($fileregex,$file)) {
array_push($photos,$file);
}
}
}
$arlength = count($photos); // Number of images in folder
//The Display Loop
sort ($photos); // THE CURRENT SORT METHOD!
foreach ($photos as $i => $file) {
$url= substr($photos[$i],0,-4);
$url = ltrim($url, "_");
echo '<td><center><a href=http://www.awesomestart.com/'.$url.'/>
<img src="non-music/'.$photos[$i].'" border="0"><br>';
include("non-music/$url.php"); echo'</a></center></td>';
$tablecount++;
if ($tablecount == 4 && ($i+1) != $arlength) {
echo'</tr><tr height="15"><td></td><td></td><td></td><td></td></tr><tr>';
$tablecount = 0;
}
}
?>