note 61477 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Sat, 02 May 2009 11:19:11 +0000 |
| Subject: | note 61477 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154125@lists.php.net to get a copy of this message | ||
Note Submitter: RobKohrPhp at remail dot robkohr dot com
----
Simplified recursive size measurement. Will also take into account the size of the folders
themselves.
<?php
function get_size($path)
{
if(!is_dir($path)) return filesize($path);
if ($handle = opendir($path)) {
$size = 0;
while (false !== ($file = readdir($handle))) {
if($file!='.' && $file!='..'){
$size += filesize($path.'/'.$file);
$size += get_size($path.'/'.$file);
}
}
closedir($handle);
return $size;
}
}
?>