string number_format(float $number [, int $decimals = 0])
string number_format(float $number , int $decimals = 0, string $decimal_point = '.', string $thousands_sep = ',')
(PHP 4, PHP 5)
| $number | The number we want to format. |
|---|---|
| $decimals | The number of decimals shown after the decimal point. |
| $decimal_point | The character string to use in place of the decimal point. |
| $thousands_sep | The character string to use in place of the thousands separator. |
| RETURNS | The number formatted according to the paramters. |
Formats a number according to the parameters given. The parameters allow you to define how many digits are shown after the decimal point ($decimals). You may also define the string to use for the $decimal_point and the $thousands_sep.
// format a number using number_format $formatted = number_format(1023.47, 2, '&mdot;', ','); echo 'Formatted Number: '.$formatted;