Re: count files

From: Date: Tue, 18 Jul 2000 15:13:13 +0000
Subject: Re: count files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7084@lists.php.net to get a copy of this message
on 7/18/00 10:57 AM, Rob Curts at rob@siliconcarne.net wrote: > on 7/18/00 11:43 AM, sarahana at sarahana@scournepal.com wrote: > >> I know that you can count the number of files in a directory through >> ASP, but I was wondering if its possible through PHP too cause I >> couldn't find such function in the manual. How do you do store all the >> filenames of a dir in an array so that you can loop and see properties >> and things like that? > > very simple > > <? > $dh = opendir("/path/to/directory"); // or c:\path\to\directory on windows > while ($f = readdir($dh)) > $Files[count($Files)] = $f; > closedir($dh); > ?> > > hope that helps > > Cheers, > Rob > sorry... i didn't add one thing: counting files is as easy as doing: sizeof($Files); once the while loop completes. Rob

« previous php.general (#7084) next »