Convert bytes to Textual Format
Login or Register to Bookmark this snippet
Returns a formatted string like 2.5kb from an integer of bytes. Goes as high as Gigabytes.
<?php
function GetSize($bytes) {
if ($bytes > 1024) {
$size_kb = $bytes / 1024;
if ($size_kb > 1024) {
$size_mb = $size_kb / 1024;
if ($size_mb > 1024) {
$size_gb = $size_mb / 1024;
} else {
}
} else {
}
} else {
$sizer = $bytes . " b";
}
return $sizer;
}
?>
Added by JC on 11th November, 2007
There are no comments about this snippet.
You must be registered and logged in to post a comment.
Login here to post a comment