/*******************************/
# 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
- MySQL stored procedure&triggers
- php questions
- Php Questions
- How we canmove into last changed position on info window close event On google map
- Pattern Matching in mysql
- MySQL INDEX
- MYSQL joins
- Jquery based dynamic adding and removal of html elements.
- securing a form with captcha
- Comparing a date with current date
0 comments
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.