/*******************************/
# function to get the byte format #
# @phpqa.blogspot.com #
/*******************************/
function getByteFormat($number,$
$unit = "";
switch($number){
case($number >= 1099511627776):
$number = round($number / 1099511627776, 1);
$unit = $caption == "small" ? "TB" : "Terabyte";
break;
case($number >= 1073741824):
$number = round($number / 1073741824, 1);
$unit = $caption == "small" ? "GB" : "Gigabyte";
break;
case($number >= 1048576):
$number = round($number / 1048576, 1);
$unit = $caption == "small" ? "MB" : "Megabyte";
break;
case($num >= 1024):
$number = round($number / 1024, 1);
$unit = $caption == "small" ? "KB" : "Kilobyte";
break;
default:
$unit = $caption == "small" ? "B" : "Byte";
$number = $number;
break;
}
return number_format($number, 2).' '.$unit;
}
# How to use #
echo getByteFormat(10995116277,"
echo getByteFormat(109951162799,"
echo getByteFormat(10995116261099);
?>
please try this function and lemme give your feedback as comments
[Thursday, August 13, 2009
|
0
comments
]
Popular Posts
- Jquery based dynamic adding and removal of html elements.
- php question
- Questoin regarding classes
- Contact Me
- Creating Google map and adding markers ans polyline on it
- creating dynamic elements in HTML using Javascript.
- Some htaccess tips
- functiion for MD5 encrypting and decrypting
- Php Questions
- PHP Question and answers
0 comments
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.