Re: Detecting PDF files in a folder and sorting them by date
- From: "NC" <nc@xxxxxxxxx>
- Date: 31 May 2005 10:52:10 -0700
bissatch@xxxxxxxxxxx wrote:
>
> I am about to write an application that will display all pdf files
> in a folder and display them by file name in order of date.
>
> Is there an easy way of doing this?
$names = array();
$dates = array();
if ($handle = opendir('/path/to/files')) {
while (false !== ($file = readdir($handle))) {
if (strlen($file) - strpos(strtoupper($file), '.PDF') == 4) {
$names[] = $file;
$dates[] = filectime($file);
}
}
closedir($handle);
}
asort($dates);
foreach ($dates as $key=>$value) {
$file = $files[$key];
$date = date('Y-m-d', $value);
echo "<p><a href='$file'>$file ($date)</a></p>";
}
Cheers,
NC
.
- References:
- Detecting PDF files in a folder and sorting them by date
- From: bissatch
- Detecting PDF files in a folder and sorting them by date
- Prev by Date: input SQL data through text box and get nothing?
- Next by Date: Re: Detecting PDF files in a folder and sorting them by date
- Previous by thread: Detecting PDF files in a folder and sorting them by date
- Next by thread: Re: Detecting PDF files in a folder and sorting them by date
- Index(es):
Relevant Pages
|