I've been using this script with no problems but recently I was asked if I could get the listings in alphabetical order. Any easy ideas?
Thanks, ds
Code: Select all
function direcho($path)
{global $filetotal, $totaldirs; if ($dir = opendir($path))
{while (false !== ($file = (readdir($dir)))) {
if (is_dir($path."/".$file)) {
if ($file != '.' && $file != '..') {
echo '<div class="folder">'.$file.'';
direcho($path."/".$file);
echo "</div>";
$totaldirs++;}} else {
$string = $path."/".$file;
$bytes = filesize($string);
$decimal = '2';
$position = 0;
$units = array( " Bytes", " KB", " MB", " GB", " TB" );
while( $bytes >= 1024 && ( $bytes / 1024 ) >= 1 ) {
$bytes /= 1024;
$position++;
}
$sizable = round( $bytes, $decimal ) . $units[$position];
$creation = date ("M d Y H:i:s.", filectime($string));
$string = rawurlencode($string);
$string = str_replace("%2F", "/", $string);
$extension = strtoupper(substr(strrchr($file, "."),1));
echo '<div class="doc"><a href = '.$string.' target="window" title="'.$extension.' File, '.$sizable.', '.$creation.'">'.str_replace((strtolower(substr(strrchr($file, "."),0))), "", $file).'</a></div>';
$filetotal++;}}closedir($dir);}}