Click to See Complete Forum and Search --> : sort folders by creation time?


m.i.c.
05-07-2007, 09:45 AM
Hi,

i would like to get a php program to order some folders by the time that they were created.
I have looked on php.net and in my literature, but i don't find an anwser...

Does anybody know if this is possible?

Thanks!

Charles
05-07-2007, 10:47 AM
$dirs = array();
foreach (glob('*', GLOB_ONLYDIR) as $filename) {
$stat = stat ($filename);
$dirs[$stat ['mtime']] = $filename;
}
krsort ($dirs, SORT_NUMERIC);

m.i.c.
05-07-2007, 11:29 AM
thank you very much!

bokeh
05-07-2007, 03:03 PM
array_multisort(array_map('filemtime', $dirs), SORT_DESC, $dirs);