Definition and usage
The Number_format () function formats numbers by using thousands of groupings.
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 with no decimal point and comma (,) as the delimiter.
Decimals is optional. How many decimal places are specified. If this parameter is set, the number is formatted with a dot (.) as the decimal point.
Decimalpoint is optional. Specifies a string to use as a decimal point.
Separator is optional. Specifies the string to use as the thousand separator. Only the first character of the parameter is used. For example, "XYZ" only outputs "X".
Note: If this parameter is set, all other parameters are required.
Hints and Notes
Note: The function supports one, two, or four parameters (not three).
Example:
Copy the Code code as follows:
Echo Number_format ("1000000");
Echo Number_format ("1000000", 2);
Echo Number_format ("1000000", 2, ",", ".");
?>
Output:
Copy the Code code as follows:
1,000,000
1,000,000.00
1.000.000,00
http://www.bkjia.com/PHPjc/328074.html www.bkjia.com true http://www.bkjia.com/PHPjc/328074.html techarticle define and use the Number_format () function to format numbers by using thousands of groupings. The syntax Number_format (number,decimals,decimalpoint,separator) parameter describes number required. To format ...