Home > Backend Development > PHP Tutorial > PHP number formatting_PHP tutorial

PHP number formatting_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:59:39
Original
912 people have browsed it

For example, echo number_format(285266237);

can output 285,266,237

In addition, if you need to format the file byte size, the following method 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(285266237);
The displayed result is 272M

For example, echo number_format(285266237);
can output 285,266,237
In addition, if you need to format the file byte size, the following method 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317301.htmlTechArticleFor example, echonumber_format(285266237); can output 285,266,237. In addition, if you need to format the file byte size, the following method can Learn from: functionbyte_format($input,$dec=0) { $p...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template