Definition and usage
The number_format() function formats numbers by grouping thousands of digits.
grammar
number_format(number,decimals,decimalpoint,separator)
Parameter description
number Required. The number to format. If no other parameters are set, the number is formatted without a decimal point and is a comma (,) as the separator.
Decimals are optional.Specify how many decimals. If this parameter is set, the number (.) is used as the decimal point to format the number.
decimalpoint optional. Specifies a string used as a decimal point.
separator optional.Specifies a string used as a thousand separator. Use only the first character of this parameter. For example, "xyz" only outputs "x".
Note: If this parameter is set, all other parameters are required.
Tips and comments
Note: This function supports one, two, or four parameters (not three).
example:
<?php
echo number_format("1000000");
echo number_format("1000000",2);
echo number_format("1000000",2,",",".");
?>
Output:
1,000,000
1,000,000.00
1.000.000,00