note 61477 modified in function.filesize by danbrown

From: Date: Sun, 18 Jan 2009 18:10:02 +0000
Subject: note 61477 modified in function.filesize by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149417@lists.php.net to get a copy of this message
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; } } ?> --was-- Simplified recursive size measurement. Will also take into account the size of the folders themselves. 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; } } http://php.net/manual/en/function.filesize.php

« previous php.notes (#149417) next »