Jump to content

sorting files by date created?


jdubwelch

Recommended Posts

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

Archived

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

×
×
  • Create New...

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.