I'm displaying the contents of a folder, with each file clickable.
I can't seem to get it to sort by file date, with the most current on top (descending).
What am I missing here?
<?php echo "<h1>File Listing</h1>"; $content_array = array(); $path = "../FOLDER/Subfolder/"; $dh = opendir($path); $handle=opendir($dirname); $i=0; while (($file = readdir($dh)) !== false) { if ($file != "." && $file != "..") { $content_array[$i][0] = $file; $content_array[$i][1] = date ("Y m d", filemtime($dirname."/".$file)); $i++; } foreach($content_array as $res) $sortAux[] = $res[1]; array_multisort($sortAux, SORT_DESC, $content_array); echo "<a href='$path/$file' target=\"\_blank>$file</a><br />"; } closedir($dh); ?>