Re: [PHP4BETA] When using readdir()

From: Date: Tue, 30 Nov 1999 23:02:42 +0000
Subject: Re: [PHP4BETA] When using readdir()
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-7132@lists.php.net to get a copy of this message
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

« previous php.version4 (#7132) next »