RE: [PHP] A Quick One - Count Files
| From: | Wagner Teixeira | Date: | Tue, 08 Aug 2000 22:52:21 +0000 |
| Subject: | RE: [PHP] A Quick One - Count Files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-10797@lists.php.net to get a copy of this message | ||
> Never mind... ignore my brain lapse. This'll work:
>
> <?php
> $dir = opendir('/var/www/C003703/gather/news') or die('Could
> not open news
> directory.');
> while ($file = readdir($dir)){
> $files[] = $file;
> }
> closedir($dir);
> print count($files);
> ?>
This will count dirs and other kind of special files also. If you want only
regular files you have to test after each readdir: if( isfile( $path . "/" .
$file ) ) ...
Wagner.