Re: Directory Listing in an Array
| From: | David Robley | Date: | Tue, 21 Aug 2001 03:18:14 +0000 |
| Subject: | Re: Directory Listing in an Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-63610@lists.php.net to get a copy of this message | ||
On Tue, 21 Aug 2001 12:35, Chris Aitken wrote:
> Hey all,
>
> 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.
>
> Am I pissing into a windy pipe dream or is there a simple solution for
> this ?
>
>
>
> Cheers
>
This, ever so slightly adapted from the example in the docs for readdir,
should do what you want
<?php
$handle=opendir(.); // replace . with whatever
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "$file\n";
$file_ary[] = $file; //The extra bit:-)
}
}
closedir($handle);
?>
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
"My stereo's half-fixed," said Tom monotonously.