The number_format() function is used to format a number with grouped thousands.
Syntax
number_format(num,decimals,decimal_pt,separator)
Parameters
num − The number to be formatted.
decimals − Specifies how many decimals.
decimal_pt − The string to be used for decimal point.
separator − Specifies the string to be used for thousands separator.
Return
The number_format() function returns the formatted number.
Example
The following is an example −
<?php echo number_format("10000000"); ?>
Output
The following is the output −
10,000,000
Example
Let us see another example −
<?php echo number_format("3999.9, 2"); ?>
Output
The following is the output −
4,000