number_format (1234.567); //Returns the number 1,235 number_format (1234.567, 2); //Returns the number 1,234.57 number_format (1234.567, 2, ',', ' '); //Returns the number 1 234,57 number_format (1234.567, 1, 'a', 'b'); //Returns the number 1b234a6
Friday, October 7, 2011
Use number_format() function in PHP
You can use the PHP function number_format to format a number in several ways, including choosing how many decimal points it will have, and choosing the 1000s, and decimal point dividers. It is phrased as number_format ( your_number , optional_decimals , optional_decimal_point, optional_1000_separator ) You can not specify just the decimal point or 1000 separator, if you specify one you need to specify both. When working with decimals, it will function like round () and put things at or over .5 up, and under .5 down.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment