Jump to content

Archived

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

jdubwelch

sorting files by date created?

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]

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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]

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.