← All built-ins / number_format()
number_format()
number_format(...$args): string
Parameters
| Name | Type | Description |
|---|---|---|
| $num | float|int | number to format |
| $decimals | int | decimal places (default 0)optional |
| $dec_point | string | decimal separator (default ".")optional |
| $thousands_sep | string | thousands separator (default ",")optional |
Return value
The formatted number string.
Example
echo number_format(1234567.891), " "; echo number_format(1234567.891, 2), " "; echo number_format(1234567.891, 2, ",", "."), " ";
1,234,568 1,234,567.89 1.234.567,89