The number_format () function uses a thousand-bit grouping to format numbers.
The number_format () function uses a thousand-bit grouping to format numbers.
The number_format () function uses a thousand-bit grouping to format numbers.
Syntax
Number_format (number, decimals, decimalpoint, separator)
Tips and comments
Note: This function supports one, two, or four parameters (not three ).
Example
The Code is as follows:
Echo number_format ("1000000 ");
Echo number_format ("1000000", 2 );
Echo number_format ("1000000", 2 ,",",".");
?>
Output:
1,000,000
1,000,000.00
1.000.000, 00
Interesting number_format
Number_format (number, decimals, decimalpoint, separator)
There are four parameters,
The first and second parameters are required, and the third and fourth parameters are optional. However, in actual tests, the third and fourth parameters must both exist, that is, either set or not set.
The third and fourth parameters are not set:
Number_format (13526, 2); echo 13,526.00;
If you accumulate the processed number, only 13 is returned !.
Set the third and fourth parameters.
Number_format (23125, 2, '.', ''); echo 23125.00;
Then, if you perform an operation on the processed number, it will be executed correctly!
The third parameter of this function indicates the position of the 'decimal point '. It can be set to', 'or other symbols by default. Ps: but I believe no one will do this.
The fourth parameter indicates what is used to separate numbers every thousands of digits. If there are no special requirements, it is best to set it to null if you want to perform computation again.