Pages

PHP number_format Function

The number_format function in PHP is used to set the format of a numerical output. The syntax of thenumber_format function is:
number_format (number, [number_of_decimals], [decimal_character], [thousand_separator_character])
where the optional parameter number_of_decimals is how many digits to display after the decimal point. The optional parameter decimal_character specifies the character to use as a decimal ('.' is the default). The optional parameter thousad_separator_character is the character to use as the thousand separator (',' is the default).
Let's take a look at the examples below:
Example 1
print number_format(1.532, 1);
Result:
1.5
Example 2
print number_format(5432.105, 3, ',', '.');
Result:
5.432,105
Note this is the number format that's used in Europe.

If you like this please Link Back to this article...



0 comments:

Post a Comment