PHP number_format() Function


The number_format() function formats numbers grouped by thousands. This function supports 1, 2, or 4 parameters (not 3).

Syntax
number_format(number,decimals,decimalpoint,separator)
Parameters
  • number - (Required) Number to format. If no other parameters are specified, the number is formatted without a decimal point and with a comma (,) as the thousands separator.
  • decimals - (Optional) Indicates the number of digits to the right of the decimal point. If this parameter is set, numbers are formatted using a period (.) as a decimal separator.
  • decimalpoint - (Optional) Specifies the string to use as the decimal point.
  • separator - (Optional) Specifies the string to use as the thousands separator. Only the first character of the delimiter is used. For example, "xxx" returns the same output as "x". If you specify this parameter, all other parameters are also required.
Example
<?php
echo nl2br("Hi Hello \n Welcome");
?>

Output

Hi Hello
Welcome

Prev Next