PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$fileregex = "[gif]"; // Specify only .gif files
$all = opendir('gallery/Movie'); // Define image folder
$photos = array(); // Define array
// Fill the photo 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
for ($i=$arlength-1; $i>$arlength-5; $i--) {
$url= substr($photos[$i],0,-4);
$url = ltrim($url, "_");
// "The" Exceptions
if ($url == 'birthdaymassacre') {
$url = 'tbm'; }
if ($url == 'faint') {
$url = 'thefaint'; }
if ($url == 'beatles') {
$url = 'thebeatles'; }
echo '<td><center><a href=http://www.awesomestart.com/'.$url.'/>
<img src="gallery/Movie/'.$photos[$i].'" border="0" width="122" height="85"><br>';
include("gallery/Movie/$url.php"); echo'</a></center></td>';
}
?>
That particular batch of code displays the four movie thumbnails on the main page. What do I have to add to it in order to display the four NEWEST (most recently uploaded, updated, whatever) images?
and echo it right after the file name (for testing purposes.) Now I just need to figure out how to sort these by this number rather than the alaphanumeric way I've been doing it: