note 57568 deleted from function.opendir by cmb
| From: | cmb@php.net | Date: | Tue, 11 Jun 2019 06:41:35 +0000 |
| Subject: | note 57568 deleted from function.opendir by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211229@lists.php.net to get a copy of this message | ||
Note Submitter: asharm4 at ilstu dot edu
----
//this is a function I wrote to sort out the contents of the directory date wise for display.
$content_array = array();
//set current working directory
$dirname = "C:\temp";
//Load Directory Into Array
$handle=opendir($dirname);
$i=0;
while ($file = readdir($handle))
if ($file != "." && $file != "..")
{
$content_array[$i][0] = $file;
$content_array[$i][1] = date ("Y m d", filemtime($dirname."/".$file));
$i++;
}
//close the directory handle
closedir($handle);
//these lines sort the contents of the directory by the date
foreach($content_array as $res)
$sortAux[] = $res[1];
array_multisort($sortAux, SORT_ASC, $content_array);