Re: dir()
| From: | David Robley | Date: | Thu, 06 Jul 2000 07:37:01 +0000 |
| Subject: | Re: dir() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5179@lists.php.net to get a copy of this message | ||
On 6 Jul, Comron E Sattari wrote:
> hey,
>
> I'm trying to use dir() to get a listing of subdirectories... but i am
> failing.
>
> here is the code, but it is only echo'ing files, no directories...
>
>
> $i = 0;
> $d = dir("./image.db");
> while($entry=$d->read())
> {
> echo $entry . "<BR>";
> if ( is_dir($entry) )
>
> $array[$i++] = $entry; }
> }
> $d->close();
> /*echo count($array); debug*/
>
> for($i = 0; $i < count($array); $i++)
> {
> echo $array[$i];
> }
>
>
> thanks,
> comron
You may need to prepend the directory name to $entry before you test if
it is a directory, otherwise the test will be made in the current
working directory, which may not be what you want.
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA