number
UK[ˈnʌmbə(r)] US[ˈnʌmbɚ]
n.Quantity; number; number; number
v. Label; total; count... as
Third person singular: numbers Plural: numbers Present participle: numbering Past tense: numbered Past participle: numbered
format
UK[ˈfɔ:mæt] US[ˈfɔ:rmæt]
n. (Publication) format; [Auto] (Data arrangement) form; TV program overall arrangement (or plan)
vt. To format; to arrange the pattern of…; to design the layout of…
vi. To design a layout
Third person singular: formats Plural: formats Present participle: formatting Past Formula: formatted Past participle: formatted
php number_format() function syntax
How to use the number_format() function?
php number_format() function means to format numbers by thousands grouping. The syntax is number_format(number,decimals,decimalpoint,separator). This function supports one, two or four parameters (not three). If no parameters other than number are set, the number will be formatted without a decimal point and with a comma (,) as the thousands separator.
Function: Format numbers by thousands grouping
Syntax: number_format(number,decimals,decimalpoint,separator)
Parameters:
Parameters | Description |
number | Required, specifies the number to be formatted |
decimals | Optional, specifies the number of decimals, if this parameter is set, use dots (.) as a decimal point to format numbers. |
decimalpoint | Optional, specifies the string used as the decimal point |
separator | Optional , specifying the string used as the thousand separator, using only the first character of the parameter, for example, "XXX" only outputs "X". If this parameter is set, all other parameters are required. |
Description: This function supports one, two or four parameters (not three). If no parameters other than number are set, the number will be formatted without a decimal point and with a comma (,) as the thousands separator.
php number_format() function example
<?php $i = 4999.9; $j = number_format($i); echo "不带参数时输出".$j."<br/><br />"; $i = 5000; $j = number_format($i,2);//设置参数,规定有两位小数 echo "带参数时输出".$j; ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
不带参数时输出5,000 带参数时输出5,000.00