note 74424 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 18:58:17 +0000
Subject: note 74424 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126491@lists.php.net to get a copy of this message
Note Submitter: kkettinger at gmail dot com ---- Here is a simple function which shows you the filesize of an dir, with sub-dirs. Sry 4 bad english :). <?php function du ($dir){ if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $path=$dir.$file; if (is_dir($path)) { $filesize+=du($path."/"); } elseif (is_file($path)) { $filesize+=filesize($path); } } } } return $filesize; } echo du("./test/"); // Output: 867435 ?>

« previous php.notes (#126491) next »