kat2481 Posted March 14, 2006 Share Posted March 14, 2006 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 Link to comment https://forums.phpfreaks.com/topic/4988-how-do-i-sort/ Share on other sites More sharing options...
hitman6003 Posted March 15, 2006 Share Posted March 15, 2006 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] Link to comment https://forums.phpfreaks.com/topic/4988-how-do-i-sort/#findComment-17617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.