← All built-ins / number_format()

number_format()

number_format(...$args): string

Parameters

NameTypeDescription
$numfloat|intnumber to format
$decimalsintdecimal places (default 0)optional
$dec_pointstringdecimal separator (default ".")optional
$thousands_sepstringthousands 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

See also

round()sprintf()