note 46581 added to function.filesize

From: Date: Fri, 15 Oct 2004 23:47:11 +0000
Subject: note 46581 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-78623@lists.php.net to get a copy of this message
I am reposting this code as I have descovered that people are ripping it off and caliming authorship. This was removed from php.net and I have no idea why, the date of the original post was 02-Apr-2004 04:12: Original Post: ======================================= 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 ======================================= ---- Manual Page -- http://www.php.net/manual/en/function.filesize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46581 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46581&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46581&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46581&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46581&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46581&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46581&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46581&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78623) next »