PHPize Online / SQLize Online

Donate Popular

number_format

Tags: PHP 5.x PHP 7.x PHP 8.x

number_format — Format a number with grouped thousands.

Description

number_format(
    float $num,
int $decimals = 0,
?string $decimal_separator = ".",
?string $thousands_separator = ","
): string
Formats a number with grouped thousands and optionally decimal digits.

Parameters

num
The number being formatted.
decimals
The number of decimal digits to display.
decimal_separator
The character(s) to use as the decimal point.
thousands_separator
The character(s) to use as the thousands separator.

Return Values

A formatted version of num.

number_format - New snippets