RE: [PHP] select 3 files that were created last
| From: | Andrew Braund | Date: | Sun, 12 Aug 2001 04:43:49 +0000 |
| Subject: | RE: [PHP] select 3 files that were created last | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62290@lists.php.net to get a copy of this message | ||
I use this function (on windows) to get a sorted list of files in a directory.
If you are going to use it on *nix it might need some adjustment.
HTH
Andrew Braund
// Reads a directory and puts filenames into a array sorted by date
function GetFilesByDate ($DataPath, &$files, &$nfiles) {
$handle=@opendir($DataPath);
if ($handle) {
$nfiles = 0;
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != ".." ) {
$files[$nfiles][name] = $file;
$files[$nfiles][date] = filemtime($DataPath."\\".$file);
$nfiles++;
}
}
closedir($handle);
if($nfiles>1){
usort($files,
create_function(
'$a,$b',
'return
$a["date"]==$b["date"]?0:($a["date"]<$b["date"]?1:-1);')
);
}
}
}
> -----Original Message-----
> From: sarahana [mailto:stellar@sarahana.com]
> Sent: Monday, 13 August 2001 03:58
> To: php-general@lists.php.net
> Subject: [PHP] select 3 files that were created last
>
>
> Hi,
> Please let me know how I can select 3 files from a directory that were last
> created..
>
> Also, the directory (out of all the directories placed in the parent
> directory) that was last created.
>
> Thanks,
> sarahana
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>