Home > Article > Backend Development > number_format() function in PHP
number_format() function is used to format numbers grouped by thousands.
number_format(num,decimals,decimal_pt,separator)
##num - The number to format.
decimals - Specifies the number of decimal places.
decimal_pt - String to use for the decimal point.
Separator - Specifies the string used for the thousands separator.
<?php echo number_format("10000000"); ?>OutputThe following is the output-
10,000,000ExampleLet’s see another example- Live Demonstration
<?php echo number_format("3999.9, 2"); ?>OutputHere is the output-
4,000
The above is the detailed content of number_format() function in PHP. For more information, please follow other related articles on the PHP Chinese website!