KODE PPC ANDA
PHP function number_format is used 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.
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
Rounding and Formatting Numbers
1. Round () - Rounding Numbers
2. Ceil () - Always Rounding Up
3. Floor () - Always Rounding Down
4. Number_format () - Formatting your Numbers
Source: php.about.com KODE PPC ANDA
0 comments
Post a Comment