Re: fopen and sort by date modified
| From: | Bas Jobsen | Date: | Wed, 14 Aug 2002 10:47:33 +0000 |
| Subject: | Re: fopen and sort by date modified | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112519@lists.php.net to get a copy of this message | ||
Op woensdag 14 augustus 2002 13:04, schreef electroteque:
> hi there i was wondering how i could fopen a directory and then sort the
> files by date modified is there a way ?
<?php
// Note that !== did not exist until 4.0.0-RC2
$dir='/home';
if ($handle = opendir($dir))
{
echo "Directory handle: $handle\n";
$lasttime=0;
$temp=array();
while (false !== ($file = readdir($handle)))
{
echo $file;
if(is_file($file))$temp[$file]=filemtime($file);
}
}
asort($temp,SORT_NUMERIC);
reset($temp);
while(list($k,$v)=each($temp))
echo $k.':'.date('r',$v)."\n";
?>