Re: [PHP4BETA] When using readdir()
| From: | Matt Greene | Date: | Tue, 30 Nov 1999 23:10:17 +0000 |
| Subject: | Re: [PHP4BETA] When using readdir() | ||
| References: | 1 2 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-7134@lists.php.net to get a copy of this message | ||
Ok thankyou, I also forgot to mention that what if i only want to disply the
directories in the current directory?
----- Original Message -----
From: Lars Torben Wilson <torben@pinc.com>
To: Matt Greene <matt@cne-c.com>
Cc: PHP4beta Mailing List <php4beta@lists.php.net>
Sent: Tuesday, November 30, 1999 6:02 PM
Subject: Re: [PHP4BETA] When using readdir()
> Matt Greene writes:
> >
> > How is it that I can use read dir but have it only display files with
like a
> > .html or .php extension?
> > Here is my Current code:
> >
> > $handle=opendir('.');
> > while ($file = readdir($handle)) {
> > echo "$file<br>\n";
> > }
> > closedir($handle);
>
> There are various ways of doing it, but the following comes first to
> mind:
>
> <?php
> $handle=opendir('.');
> while ($file = readdir($handle)) {
> $ext = strrchr( $file, '.' );
> if ( $ext == '.html' || $ext == '.php' ) {
> echo "$file<br>\n";
> }
> }
> closedir($handle);
> ?>
>
>
> Torben
>