note 53750 deleted from function.filesize by aidan

From: Date: Wed, 13 Jul 2005 03:17:40 +0000
Subject: note 53750 deleted from function.filesize by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-91859@lists.php.net to get a copy of this message
Note Submitter: Jonas Mårtensson ---- a simple and imo good function for calculating size of a dir and all files in it. will return the value in bytes. and if it's not a dir it will return 0 <? function size_of_dir($str_dir) { $int_size = 0; if (is_dir($str_dir)) { if ($dh = opendir($str_dir)) { while (($file = readdir($dh)) != false) { if($file != "." && $file != "..") { if(is_dir($str_dir . $file)) { $int_size += size_of_dir($str_dir."/".$file); } else { $int_size += filesize($str_dir."/".$file); } } } } } closedir($dh); return $int_size; } ?>

« previous php.notes (#91859) next »