I have a web page that takes in a path and searches for files based on user input. An example would be the user entering C:\folder_name\*.txt now my php will output all files in C:\folder_name\ with anything and then the extension .txt. I use the glob function to search because it works fantastic. Here is my problem, some folders with which this program will run are extremely big (over 10s of 1000s of files). I would like to return maybe 20 or 30 names unless the user specifies otherwise. I can do that with a simple counter, but I want to display the most recent file names. Meaning if a.txt a1.txt a2.txt were modified on 08/08 and d.txt d1.txt d2.txt were modified on 08/09 I want them to take priority over the a files because they are more recent. So is there anyway to sort the glob array based on the most recently updated files. Here is the basic syntax of how my output works. I made it as simple as possible for reading sake.
$arrayPath = glob("C:\folder_name\*.txt");
foreach($arrayPath as $i){
echo($i);
}