PHP Math number format


the number_format() function: formats the number by thousands of groups and returns the formatted string.

grammar:

string number_format(float number[, int decimals[, string dec_point, string thousands_sep]])
parameter Description
number Required, number to format
decimals Optional, specify how many decimal places.
dec_point Optional, specifies the string to use as the decimal point(defaults to.).
thousands_sep Optional, specifies the string to use as the thousands separator(defaults to), and if set, all other parameters are required.

example:

echo number_format(10000); // Output: 10,000
echo number_format(10000,2); // Output: 10,000.00
echo number_format(10000,2, '.', ''); // Output: 10 000.00
echo number_format(10000,2, '.', ''); // Output: 10000.00

Tip

The function supports one, two, or four arguments.




Copyright 2014-2017 by DeveloperTut.com. All Rights Reserved.
TwitterGoogle+Facebook