Introduction to php number formatting function number_format

PHP中文网
Release: 2023-02-28 20:10:02
Original
3090 people have browsed it
php Number formatting function number_format Introduction, number_format (the number to be formatted, the number of decimal places to be retained, the decimal point string , thousands separator).

number_format functionnumber_format (number to be formatted, number of decimal places to be retained, decimal point string, thousands separator) // 4 parameters in total The number_format function is used to format numbers. Among the four parameters listed above, the first one is required and the others are optional. Parameter Description: Number to format (not interpreted) Number of decimal places to keep (optional) How many decimal places to keep after formatting the number Decimal point string (optional) The default is . If you want to use the * sign as the decimal point, the parameter value is * For example: 189*00 (189 retains 2 decimal places, * is the decimal point) Thousands separator (optional) The default is , if you want to specify other symbols to separate thousands, the parameter value is the semicolon to be specified. For example: 189^000^000.00 Here the symbol ^ is used as the thousands separator. Example:

number_format(288);
--输出 288
 
number_format(365,2);
--输出 365.00
 
number_format(365000000,3,".")  (将数字 365000000 保留3位小数,小数点用"."表示)
--输出: 365,000,000.000
 
number_format(365000000,2,".","*")  (将数字 365000000 保留2位小数,小数点用"."表示,千位分隔符用"*"表示)
--输出: 365*000*000.00
Copy after login


The above is the introduction to the PHP number formatting function number_format. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!