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;
}
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;
}
Echo byte_format