Stavros Posted April 21, 2011 Share Posted April 21, 2011 Hi all I have been trying to sort this one out for hours now. I just need to sort my list alphabetically, any advise appreciated. This what I have so far if ($handle = opendir('./Items/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $thelist .= '<a class ="preview" href=Items/'.$file.'>'.$file.'</a> <br>'; } } closedir($handle); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $Pics = array ($thelist); sort($Pics); foreach ($Pics as $key => $val) {echo "Pics[" . $key . "] = " . $val . "\n";} Link to comment https://forums.phpfreaks.com/topic/234314-sort-file-names-sort-array/ Share on other sites More sharing options...
requinix Posted April 21, 2011 Share Posted April 21, 2011 Are you outputting a JavaScript array? Do you really want the HTML in there as well? Link to comment https://forums.phpfreaks.com/topic/234314-sort-file-names-sort-array/#findComment-1204361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.