Jump to content

Archived

This topic is now archived and is closed to further replies.

kat2481

How do I sort?

Recommended Posts

How do I sort this so it displays the results alpha?

if ($handle = opendir("/home/mysite/public_html/Store/{$thestore}/Images/")) {
//echo "Directory handle: $handle\n";
//echo "Files:\n";


while (false !== ($file = readdir($handle))) {
if (strlen($file) >3){

echo "<OPTION Value = '";
echo "Store/{$thestore}/Images/{$file}";


echo "'>";
echo "$file";
echo "</OPTION>";
}
}



closedir($handle);
}

if ($handle = opendir("/home/mysite/public_html/Images/Backgrounds/")) {
//echo "Directory handle: $handle\n";
//echo "Files:\n";


while (false !== ($file = readdir($handle))) {
if (strlen($file) >3){
echo "<OPTION Value = '";
echo "Images/Backgrounds/{$file}";

echo "'>";
echo "$file";
echo "</OPTION>";
}
}



closedir($handle);
}
?>


--------
Thanks for any replies

Share this post


Link to post
Share on other sites
This should help.

[code]if ($handle = opendir("/home/mysite/public_html/Store/{$thestore}/Images/")) {
    while ($file = readdir($handle)) {
        if (strlen($file) >3){
            $files[] = $file;
        }
    }
    closedir($handle);
    
    sort($files);
    foreach ($files as $file) {
        echo "<OPTION value=\"Store/{$thestore}/Images/{$file}\">$file</OPTION>";
    }
}

if ($handle = opendir("/home/mysite/public_html/Images/Backgrounds/")) {
    ...same as above...
}[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.