note 40163 added to function.filesize

From: Date: Mon, 23 Feb 2004 22:38:08 +0000
Subject: note 40163 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-65617@lists.php.net to get a copy of this message
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; } ---- Manual Page -- http://www.php.net/manual/en/function.filesize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40163 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40163&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40163&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65617) next »