- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi All
Scoured the web and found only bits of info on my issue, but no definitive answers to my specific problem..
Remember – I’m very new to this – so pardon any mistakes or oversight on my part..
What I’ve got working is the following:
I’m making an image gallery. I have a PHP script that reads a folder and lists the sub-folders in this folder, which in turn contains images.
I need this listing of folders ( which are also echoed as links ) to be listed alphabetically:
I tried to assign a variable to an array (not shown here) – as apparently you can only sort an array, then tried to run the sort() function on this array…
Something like this :
$folder[] = $album_name;
sort($folder);
Unfortunately I get weird results…
This is a snippet of the code – can anyone assist me in getting the resultant echo to display alphabetically :
//folders
$base = "Photos";
$thumbs = "Thumbs";
//get albums
$get_album = $_GET;
if(!$get_album)
{
echo "Select an album:
";
$dirs = opendir($base);
echo ""; //wrap all albums found in a div for styling
echo "
";
while(($folder = readdir($dirs))!== FALSE)
{
if(is_dir($base."/".$folder) && $folder != "." && $folder != ".." && $folder != $thumbs)
{
echo "";
echo "$folder";
}
}
echo ""; //end album div
closedir($dirs);
I got it sorted after some effort.
Thanks to all that contemplated helping me ! ;-) hiehiehie !