Hello all, I have a problem which I can easily explain logically, but can't implement in PHP for the life of me. Basically, I have a directory listing code: $path = $_GET['files']; if(!isset($path)) { $path = "./maps"; } if ($handle = opendir($path)) { $curDir = substr($path, (strrpos(dirname($path."/."),"/")+1)); print "<B><U>Maps:</u></b><p><sub>"; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $fName = $file; $file = $path.'/'.$file; if(is_file($file)) { print "<a href='".$file."' target='_blank'>".$fName."</a><br>"; } if(is_dir($file)) { print "<a href='ex2.php?path=$file'>$fName</a><br>"; } } } closedir($handle); Code (markup): ... which outputs files from the chosen directory, in this case, "maps". If you want to see it in action, visit tf2.cawfee.us. So far, so good. Now, the folder "maps" contains files that start with certain filenames, such as ct_ or ctf_. What I'm trying to do is call these file lists once at a time on the page itself, so that all ctf_ files are listed alone, then all ct_ files via a different string, and then all remaining ones. I'm trying to achieve this so I can categorize the files on the page itself. Is this possible in PHP, or am I better off creating a database for this particular task? Thanks in advance!
Throw all the filenames in an array and sort it. Then files starting with the same characters should be next to each other.