note 80995 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Sat, 02 May 2009 11:16:14 +0000 |
| Subject: | note 80995 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154113@lists.php.net to get a copy of this message | ||
Note Submitter: Yure666
----
This is a shorter (but not faster) code for the getsize function, will work for files and folders.
<?php
function getsize($path){
if (!is_dir($path))
return filesize($path);
$size=0;
foreach (scandir($path) as $file){
if ($file=='.' or $file=='..')
continue;
$size+=getsize($path.'/'.$file);
}
return $size;
}
?>