Hello Dear Members,
I am in need of assistance with printing out the top 30 values of the below array. I cannot figure out how to initiate a looping process with the array. If you need more info I'll be glad to provide it. Thank you for your time.
<?php
//define the path
$path = "/home/abc/public_html/filepath";
//using the opendir function
$dir = @opendir($path) or die("Error 10011");
//reads the current directory
while (false !== ($file = readdir($dir))) {
$fileList[] = trim($file); //add the file to an array to be sorted
}//end while
rsort ($fileList); //sorts the filelist array in reverse order
reset ($fileList); //go back to the top of the array
while (list ($key, $val) = each ($fileList)) {
echo "<a href=\"filepath/$val\">" . $val . "</a><br />"; //print the list.
}//end while
//closing the directory
closedir($dir);
?>
The above code prints out a list as such:
100607.htm
100507.htm
100407.htm
100307.htm
100207.htm
100107.htm
...
But I only want to top 30 files to be listed and therefore need to tell the array to print out only the top 30 files with some sort of for or while loop. Again Thank You!