English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String String Functions Manual
The number_format() function is used to format a number with a thousand separator.
number_format(number,decimals,decimalpoint,separator)
The function formats numbers by grouping them in thousands.
Note: This function supports one, two, or four parameters (not three).
It returns the formatted number.
Serial Number | Parameters and Description |
---|---|
1 | number Number to be formatted |
2 | decimals Number of decimal places to retain |
3 | decimalpoint Specify the character to display as the decimal point. |
4 | separator Specify the character to display as the thousand separator. |
Try the following example, number_format() function formats numbers:
<?php //number_format() function formats numbers $input = 100.9; $formattedinput = number_format($input)."<br>"; echo $formattedinput; $formattedinput = number_format($input, 2); echo $formattedinput; ?>Test and See‹/›
Output Result
101 100.90