Re: no of files in a folder....
| From: | Richard Lynch | Date: | Wed, 03 Oct 2001 02:25:29 +0000 |
| Subject: | Re: no of files in a folder.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69668@lists.php.net to get a copy of this message | ||
You could probably http://php.net/exec some kind of shell script
to do it.
Or, something not unlike this:
# Untested code:
function count_files($directory){
static $count;
if (!isset($count)){
$count = 0;
}
$dir = opendir($directory);
while ($path = readdir($dir)){
if ($path != '.' && $path != '..'){
if (is_dir($path)){
count_files($path);
}
else{
$count++;
}
}
}
closedir($dir);
}
If you want to count directories, copy the $count++ up a couple lines.
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Sagar N Chand <sagarchand@yahoo.com>
Newsgroups: php.general
To: php <php-general@lists.php.net>
Sent: Tuesday, September 25, 2001 7:49 AM
Subject: no of files in a folder....
hi all,
is there any way out to get the total no of files in a directory including
its
subfolders ?
thanQ,,
/sagar