Page 1 of 1

Arrange Files By....

Posted: Sat Oct 19, 2002 10:28 am
by Zeceer
I got this simple script that loops thru a folder that includes the files in the folder:
<?php

$dirname = "produkter";
$dh = opendir( $dirname );

while( $file = readdir( $dh ) )
{
if(is_file("$dirname/$file"))
include("$dirname/$file");
}

?>
In the folder the files are arranged by name. But when the script includes the files, it looks like there included by the date. The oldest on top and so on. Is there any way to arrange the files another way? After name would be great.

Posted: Sat Oct 19, 2002 10:55 am
by volka
viewtopic.php?t=1241 has a quite similar topic

Posted: Sat Oct 19, 2002 11:01 am
by Zeceer
The thing here is that i'm gonna arrange the files by name, not last updatet. Don't have any ideas on have this can be done :oops:

Posted: Sat Oct 19, 2002 11:21 am
by volka
  • almost the same way
  • open a dir-descriptor
  • append all filenames to an array
  • sort that array
it's even simpler since you do not need an user-defined compare-function, sort() will do

Posted: Sat Oct 19, 2002 12:17 pm
by Zeceer
Get it. Thanx :D