jdubwelch Posted April 26, 2006 Share Posted April 26, 2006 i have a folder with 5 folders (engagement, explore, motion, motionless, and seniors). I'm going to use the $folders array to create links for the navigational part, but i don't want them to be ordered alphabetically. I was thinking, if i could sort them by the time they were created or modified I could control it that way. I've search the net and haven't found anything. How would I sort $folders array by the date the folders were created?[code]if ($handle = opendir('./files/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $folders[] = $file; } } closedir($handle);}sort($folders);print_r($folders);[/code]will output this:[code]Array ( [0] => engagement [1] => explore [2] => motion [3] => motionless [4] => seniors )[/code] Link to comment https://forums.phpfreaks.com/topic/8491-sorting-files-by-date-created/ Share on other sites More sharing options...
litebearer Posted April 26, 2006 Share Posted April 26, 2006 Look at the first two posts here[a href=\"http://us2.php.net/function.rsort\" target=\"_blank\"]http://us2.php.net/function.rsort[/a]Lite... Link to comment https://forums.phpfreaks.com/topic/8491-sorting-files-by-date-created/#findComment-31143 Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 try experimenting with the filectime() function [a href=\"http://www.php.net/manual/en/function.filectime.php\" target=\"_blank\"]Function reference for filectime (php.net)[/a] Link to comment https://forums.phpfreaks.com/topic/8491-sorting-files-by-date-created/#findComment-31148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.