note 40163 deleted from function.filesize by tomsommer

From: Date: Wed, 01 Sep 2004 17:30:58 +0000
Subject: note 40163 deleted from function.filesize by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75870@lists.php.net to get a copy of this message
Note Submitter: GABZ in OZ ---- all the PHP freaks out there ... Get the complete size of a given directory $dir (recursiv) inclusive the amount of scanned files and dirs. Returns an array with: $array[0] = amount of files scanned; $array[1] = amount of dirs scanned; $array[2] = complete size in bytes; NOTE: simply skips dirs which aren't allowed to red (by permission e.g.) There's plenty enough functions out there to convert outpout to human readable string :)) function get_size($dir) { $speicher = 0; $dateien = 0; $verz = 0; if ($handle = @opendir($dir)) { while ($file = readdir($handle)) { if($file != "." && $file != "..") { if(@is_dir($dir."/".$file)) { $wert = get_size($dir."/".$file); $speicher += $wert[2]; $dateien += $wert[0]; $verz += $wert[1]; $verz++; } else { $speicher += @filesize($dir."/".$file); $dateien++; } } } closedir($handle); } $zurueck[0] = $dateien; $zurueck[1] = $verz; $zurueck[2] = $speicher; return $zurueck; }

« previous php.notes (#75870) next »