Ordering when using PHP to list files
Posted: Wed Jan 21, 2004 9:14 am
When you use PHP to list a bunch of files in a folder, how do you order them and what is the default order?
I presume it is not file name as my results are all over the place...
Cheers for any help.
Tony.
I presume it is not file name as my results are all over the place...
Code: Select all
$path = "/home/sites/site14/web/courses/gallery/";
chdir($path);
$handle=opendir($path);
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != ".." && !is_dir($file)) {
$id = str_replace(".JPG", "", $file);
$id = str_replace(".jpg", "", $id);
$text = str_replace("_", " ", $id);
echo "<img src="/courses/gallery/".$file."" style="width:220px; height:220px; margin:0px 10px 10px 0px; ">\n";
}
}
closedir($handle);Tony.