2052 Posts in 477 Topics- by 811 Members - Latest Member: canmasagi

Pages: [1]   Go Down
  Print  
Author Topic: [PHP Code] Counting All Files  (Read 500 times)
webmaster
Administrator
phpBB Guru
*****
Offline Offline

Posts: 914


hairulazami
View Profile WWW
« on: October 31, 2008, 09:44:46 AM »

Code:
<?
function count_files($dir, $recursive=false, $counter=0)
{
static $counter;
    if(is_dir($dir))
{
if($dh = opendir($dir))
{
while(($file = readdir($dh)) !== false)
{
if($file != "." && $file != ".." && $file != ".htaccess" && $file != ".htpasswd" && $file != "Thumbs.db")
{
$counter = (is_dir($dir."/".$file)) ? num_files($dir."/".$file, $recursive, $counter) : $counter+1;
}
}
closedir($dh);
}
}
return $counter;
}

echo count_files("d:\dremi");
?>
Logged


Pages: [1]   Go Up
  Print  
 
Jump to: