note 61238 modified in function.stat by danbrown

From: Date: Thu, 16 Oct 2008 13:29:04 +0000
Subject: note 61238 modified in function.stat by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145412@lists.php.net to get a copy of this message
If you want to know a directory size, this function will help you: <?php function dir_size($dir) { $handle = opendir($dir); while ($file = readdir($handle)) { if ($file != '..' && $file != '.' && !is_dir($dir.'/'.$file)) { $mas += filesize($dir.'/'.$file); } else if (is_dir($dir.'/'.$file) && $file != '..' && $file != '.') { $mas += dir_size($dir.'/'.$file); } } return $mas; } echo dir_size('DIRECTORIO').' Bytes'; ?> --was-- If you want to know a directory size, this function will help you: <? function dir_size($dir) { $handle = opendir($dir); while ($file = readdir($handle)) { if ($file != '..' && $file != '.' && !is_dir($dir.'/'.$file)) { $mas += filesize($dir.'/'.$file); } else if (is_dir($dir.'/'.$file) && $file != '..' && $file != '.') { $mas += dir_size($dir.'/'.$file); } } return $mas; } echo dir_size('DIRECTORIO').' Bytes'; ?> http://php.net/manual/en/function.stat.php

« previous php.notes (#145412) next »