Here's one way:
$dir = opendir('.');
unset($FileList);
while ($file=readdir($dir)) {
if($file!= '.' && $file != '..')
{
$FileList[] = $file;
}
}
sort $FileList;
reset($FileList);
while(list(, $F) = each($FileList)) {
echo "$F<br>\n";
}
If you're using PHP4, you can replace everything after the
sort($FileList) with the more compact:
foreach($FileList as $F) { echo "$F<br>\n"; }
See
http://www.php.net/manual/en/function.sort.php
for more info on sorting arrays.
- steve
At 1:05 PM -0500 7/9/01, kmurrah wrote:
>Greetings.
>
>I need to read the contents of a directory, sort it alphabetically, and
>display it ....
>
>i'm doing find on the reading and displaying, but can someone help me with
>the sort?
>
>$dir = opendir(".");
>
>while ($file=readdir($dir)) {
>
>
> if($file!= "." && $file != "..")
> {
> echo("$file<br>");
> }
>}
>
--
+------ Factoid: Of the 100 largest economies in the world, 51 are ------+
| Steve Edberg University of California, Davis |
| [EMAIL PROTECTED] Computer Consultant |
| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |
+--- corporations ------ http://www.ips-dc.org/reports/top200text.htm ---+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]