PHP number_format() Function

The number_format() function in PHP formats a number with grouped thousands. This function accepts one, two, or four parameters (not three):

Syntax

            or

Parameter

number(required)- This parameter represents the number to be formatted. If no parameters are set, the number will be formatted without decimals and with comma (,) as the thousands separator.

decimals(optional)- This parameter specifies how many decimals. If this parameter is set, the number will be formatted with a dot (.) as decimal point.

decimalpoint(optional)- This parameter specifies what string to use for decimal point.

separator (optional)- This parameter specifies what string to use for thousands separator. Only the first character of separator is used.

Returns

This function returns a formatted version of number.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output

Pin It on Pinterest

Share This