| 0 comments ]

//This function is for sub directories size (This will retrn an array )
function du($location) {
if (!$location || !is_dir($location))
return 0;
$size = 0;
$files = 0;
$dirs = 0;

$all = opendir($location);
while ($file = readdir($all)) {
if (is_dir($location.'\\'.$file) and $file != ".." and $file != ".") {
$temp = du($location.'/'.$file);
$dirs++;
$size += $temp['size'];
$files += $temp['files'];
$dirs += $temp['dirs'];
unset($temp);
unset($file);
} elseif (!is_dir($location.'\\'.$file)) {
$stats = stat($location.'\\'.$file);
$size += $stats['size'];
$files++;
unset($file);
}
}
closedir($all);
unset($all);
return array('size' => $size, 'files' => $files, 'dirs' => $dirs);
}

0 comments

Post a Comment

Please put your comments here. your questions, your suggestions, also what went wrong with me.