note 41185 deleted from function.filesize by aidan

From: Date: Sun, 26 Sep 2004 00:20:10 +0000
Subject: note 41185 deleted from function.filesize by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77339@lists.php.net to get a copy of this message
Note Submitter: gnif at spacevs dot com ---- All the other functions I see on this page are just bloated if else statements, this is a nice and neat function that will calculate all the way up to EB and more if you add them to the array $sizes. function DownloadSize($file) { $size = filesize($file); $sizes = Array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'); $ext = $sizes[0]; for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; } return round($size, 2).$ext; } ---- http://www.spacevs.com/index.php?page=phpsnippets

« previous php.notes (#77339) next »