number_format() Function in Php

#Number Format Function in PHP


The number_format() function formats a number with grouped thousands.


Note: This function supports one, two, or four parameters (not three).







numberRequired. The number to be formatted. If no other parameters are set, the number will be formatted without decimals and with comma (,) as the thousands separator.
decimalsOptional. Specifies how many decimals. If this parameter is set, the number will be formatted with a dot (.) as decimal point
decimalpointOptional. Specifies what string to use for decimal point
separatorOptional. Specifies what string to use for thousands separator. Only the first character of separator is used. For example, “xxx” will give the same output as “x”

Note: If this parameter is given, all other parameters are required as well



echo number_format("1000000")."<br>";

Output: 1,000,000

// Option-2
echo number_format("1000000",2)."<br>";


echo number_format("1000000",2,",",".");

Output:: 1.000.000,00


Leave a Comment