PHP Math number format

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


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.


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


The function supports one, two, or four arguments.

Copyright 2014-2017 by All Rights Reserved.