Snipe.Net - Geeky Stuff
Twitter
Currently: @etamotweet dammit - you still there? Crap reception and my phone is almost dead in reply to etamotweet 4 hrs ago

Displaying file sizes in human readable format

This code prints out “b” for bytes, “m” for megs, etc depending on the file size.

= 1073741824) {
		$fileweight = round($fileweight / 1073741824 * 100) / 100 . "GB";
	} elseif ($fileweight >= 1048576) {
		$fileweight = round($fileweight / 1048576 * 100) / 100 . "MG";
	} elseif ($fileweight >= 1024) {
		$fileweight = round($fileweight / 1024 * 100) / 100 . "k";
	} else {
		$fileweight = $fileweight . "b";
	}
	return $fileweight;
} // end function
?> 

Also check out:

If you think this article kicked ass, subscribe to the RSS feed or follow me on Twitter! Share with your friends, or leave a comment below (or better still, do both!) My entire concept of self-worth is in your hands, so that makes you kind of a big deal. Srsly.

This entry was posted on Thursday, June 27th, 2002 at 2:28 pm and is filed under PHP/mySQL. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
blog comments powered by Disqus