Re: Directory Listing in an Array
| From: | speedboy | Date: | Tue, 21 Aug 2001 03:59:06 +0000 |
| Subject: | Re: Directory Listing in an Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-63614@lists.php.net to get a copy of this message | ||
> Just something I havent been able to sort out in the archives, but what im
> wanting to do it this. Do a listing of all files in a directory, and load
> up an array with each returned filename.
$files_dir = "/tmp";
chdir($files_dir);
$dir_handle = @opendir($files_dir) or die("Unable to open $files_dir");
$files = array();
while ($file = readdir($dir_handle)) {
array_push($files, $file);
}
closedir($dir_handle);
sort($files);
reset($files);
for ($i = 0; $i < count($files); $i++) {
echo "$files[$i] <br>";
}