note 51500 deleted from function.glob by cmb
| From: | cmb@php.net | Date: | Mon, 21 Nov 2016 19:23:52 +0000 |
| Subject: | note 51500 deleted from function.glob by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207297@lists.php.net to get a copy of this message | ||
Note Submitter: cjcommunications at gmail dot com
----
Here is a way I used glob() to browse a directory, pull the file name out, resort according to the
most recent date and format it using date(). I called the function inside a <select> and had
it go directly to the PDF file:
function browsepdf(){
$pdffile=glob("printable/*.pdf");
rsort($pdffile);
foreach($pdffile as $filename){
$filename=ltrim($filename, "printable/");
$filename=rtrim($filename, ".pdf");
$file=$filename;
$datetime=strtotime($filename);
$newdate=strtotime("+3 days",$datetime);
$filenamedate=date("F d", $datetime);
$filenamedate.=" - ".date("F d, Y", $newdate);
echo "<option value='$file'>$filenamedate</option>";
}
}