note 37838 added to function.ksort
| From: | pedromartinez at alquimiapaginas dot com | Date: | Sat, 29 Nov 2003 00:58:52 +0000 |
| Subject: | note 37838 added to function.ksort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-61101@lists.php.net to get a copy of this message | ||
A list of directories can be listed sorted by date (newer first) with this script. This is usefull
if the directories contain (for example) pictures and you want the newer to appear first.
$maindir = "." ;
$mydir = opendir($maindir) ;
// SORT
$directorios = array();
while (false !== ($fn = readdir($mydir)))
{
if (is_dir($fn) && $fn != "." && $fn != "..")
{
$directory = getcwd()."/$fn";
$key = date("Y\-m\-d\-His ", filectime($directory));
$directorios[$key] = $directory;
}
}
ksort($directorios);
$cronosdir = array();
$cronosdir = array_reverse($directorios);
while (list($key, $directory) = each($cronosdir)) {
echo "$key = $directory<bR>";
}
Pedro
----
Manual Page -- http://www.php.net/manual/en/function.ksort.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37838
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37838&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37838&report=yes
Search -- http://master.php.net/manage/user-notes.php