[SOLVED] Alphabetising Gallery Code
Posted: Mon Oct 03, 2005 1:47 pm
I have a gallery at http://www.awesomestart.com/gallery
As you can see, the "Pink Floyd" skin (the most recently added skin) is displayed at the last because the gallery organizes the files by date modified.
How can I modify the code so that the thumbnails are displayed in alphabetical order?
Here's my current code to fill the gallery.
I appreciate the help.
As you can see, the "Pink Floyd" skin (the most recently added skin) is displayed at the last because the gallery organizes the files by date modified.
How can I modify the code so that the thumbnails are displayed in alphabetical order?
Here's my current code to fill the gallery.
Code: Select all
<table border="0" width="100%" cellpadding="0" cellspacing="0"><tr>
<?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
for ($i=0; $i<$arlength; $i++) {
if ($photos[$i] != "_x.gif") {
$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;
}
}
}
?>
</td>
</tr>
</table>
<br>
<p><strong>Music:</strong></p>
<table border="0" width="100%" cellpadding="0" cellspacing="0"><tr>
<?php
$fileregex = "[gif]"; // Specify only .gif files
$all = opendir('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
$tablecount=0;
for ($i=0; $i<$arlength; $i++) {
if ($photos[$i] != "_plain.gif") {
$url= substr($photos[$i],0,-4);
$url = ltrim($url, "_");
echo '<td><center><a href=http://www.awesomestart.com/'.$url.'/>
<img src="music/'.$photos[$i].'" border="0"><br>'; include("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;
}
}
}
?>
</td>
</tr>
</table>I appreciate the help.