note 46439 deleted from function.opendir by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 11 Oct 2004 21:47:34 +0000 |
| Subject: | note 46439 deleted from function.opendir by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78367@lists.php.net to get a copy of this message | ||
Note Submitter: djchain at ikt-nett dot com
----
This is the way to put it in alphabetical order, im not sure of if its the best way to do it with
arrays, but this is something i put together in about 5 min so it will at least give you the ide.
<?php
$dir = "/usr/home/freeshell/ruant/public_html";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$array = array($file);
$r = array_merge($array, $r);
}
closedir($dh);
}
}
sort($r);
$tall = count($r);
$i = 0;
while ($i != $tall) {
$i++;
echo "<a href='$r[$i]'>$r[$i]</a><br>";
}
?>