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 "不帶參數(shù)時輸出".$j."<br/><br />"; $i = 5000; $j = number_format($i,2);//設(shè)置參數(shù),規(guī)定有兩位小數(shù) echo "帶參數(shù)時輸出".$j; ?>
Run instance?
Click the "Run instance" button to view the online instance
Output:
不帶參數(shù)時輸出5,000 帶參數(shù)時輸出5,000.00