Page 1 of 1

Ordering files from a folder?

Posted: Mon Oct 06, 2003 5:04 pm
by Mr. Tech
You know when you use this code to select files out of a folder:

Code: Select all

<?php
$handle=opendir(".");
while ($file = readdir($handle)) {
	if (is_file("./$file")) {
		print $file;
}
closedir($handle); 
?>
It orders them alpabetically. Is it possible to change the way it is ordered? ASC, DESC, extensions etc...

Thanks

Posted: Mon Oct 06, 2003 5:22 pm
by mudkicker
you can take them to an array and use then array functions like sort etc..