Re: [PHP4BETA] When using readdir()

From: Date: Tue, 30 Nov 1999 23:58:41 +0000
Subject: Re: [PHP4BETA] When using readdir()
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-7139@lists.php.net to get a copy of this message
On Tue, Nov 30, 1999 at 03:02:42PM -0800, Lars Torben Wilson wrote: > 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)) { Note that this version does not work, if the directory contains a file called "0". > $ext = strrchr( $file, '.' ); > if ( $ext == '.html' || $ext == '.php' ) { > echo "$file<br>\n"; > } > } > closedir($handle); > ?> > > > Torben > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net -- Regards, Sascha Schumann Consultant

« previous php.version4 (#7139) next »