I have this snippet of code I'm attempting, it is supposed to loop through a subdirectory and list all the files therein. I also want it to list the files in date order, newest first. I want the date, filename, and file size all listed in the display.
Sooo..from various tutorials on the web this is what I have come up with (no the sort isn't working yet):
$dirpath = getcwd() . "/minutes/";
$dir = opendir($dirpath);
$files = array();
$ar2 = array();
$arrC = 0;
$arrC2 = 0;
$arrC3 = 0;
while ($file = readdir($dir)) {
$localpath = $dirpath.$file;
if (is_file($localpath)) {
$uts=filemtime($localpath);
$filedate = date ('m/d/Y g:i:s A', $uts);
$filebig = filesize($localpath);
$ar2[$arrC][$arrC2][$arrC3] = $filedate;
$arrC2++;
$ar2[$arrC][$arrC2][$arrC3] = $file;
$arrC3++;
$ar2[$arrC][$arrC2][$arrC3] = $filebig;
$key = filemtime($localpath).md5($file);
$files[$key] = $file;
$arrC++;
$arrC2++;
$arrC3++;
}
}
ksort($ar2);
foreach ($ar2 as $x1) {
echo "<tr>";
foreach ($x1 as $y2) {
foreach ($y2 as $x3) {
echo "<td width=150> $x3 </td>";
}
}
echo "</tr>";
}
closedir($dir);
I am very, very new to PHP and would love and appreciate some help. Is there a better way to do this? The sort works on the array's key... but, not sure how it'd work. The sort doesn't work here. Also note, there is some extra array stuff in there that's not quite used but I didn't want to take out yet. 🙂
Thanks. 🙂