note 94280 added to function.filesize
| From: | Kevin at osu1 dot php dot net | Date: | Tue, 27 Oct 2009 00:44:50 +0000 |
| Subject: | note 94280 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162135@lists.php.net to get a copy of this message | ||
// Get the size of all files within a directory
function dirSize($dir) {
$totalSize = 0;
$fileCount = 0;
$dirCount = 0;
$files = glob($dir.'*', GLOB_MARK);
foreach( $files as $file ){
if( substr($file, -1) == '/' || substr($file, -1) == '\\' ) {
$result = dirSize($file);
$dirCount++;
$totalSize += $result['size'];
$fileCount += $result['fileCount'];
$dirCount += $result['dirCount'];
}
else {
$totalSize += filesize($file);
$fileCount++;
}
}
$total['size'] = $totalSize;
$total['fileCount'] = $fileCount;
$total['dirCount'] = $dirCount;
return $total;
}
----
Server IP: 69.147.83.197
Probable Submitter: 173.21.30.148
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- https://master.php.net/note/edit/94280
Del: integrated -- https://master.php.net/note/delete/94280/integrated
Del: useless -- https://master.php.net/note/delete/94280/useless
Del: bad code -- https://master.php.net/note/delete/94280/bad+code
Del: spam -- https://master.php.net/note/delete/94280/spam
Del: non-english -- https://master.php.net/note/delete/94280/non-english
Del: in docs -- https://master.php.net/note/delete/94280/in+docs
Del: other reasons-- https://master.php.net/note/delete/94280
Reject -- https://master.php.net/note/reject/94280
Search -- https://master.php.net/manage/user-notes.php