In addition, if you need to format the file size in bytes, the following methods can be used for reference:
Function byte_format ($ input, $ dec = 0)
{
$ Prefix_arr = array ('B', 'K', 'M', 'G', 'T ');
$ Value = round ($ input, $ dec );
$ I = 0;
While ($ value> 1024)
{
$ Value/= 1024;
$ I ++;
}
$ Return_str = round ($ value, $ dec). $ prefix_arr [$ I];
Return $ return_str;
}
Response byte_format (285266237 );
The result is 272 MB.
For example, echo number_format (285266237 );
Output 285,266,237
In addition, if you need to format the file size in bytes, the following methods can be used for reference:
Function byte_format ($ input, $ dec = 0)
{
$ Prefix_arr = array ('B', 'K', 'M', 'G', 'T ');
$ Value = round ($ input, $ dec );
$ I = 0;
While ($ value> 1024)
{
$ Value/= 1024;
$ I ++;
}
$ Return_str = round ($ value, $ dec). $ prefix_arr [$ I];
Return $ return_str;
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.