Formatting Numbers

Posted by exemedia | 1:23 AM | | 0 comments »
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

Digg Technorati del.icio.us Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy

Related Posts by Categories



Widget by Hoctro | Jack Book

0 comments

Post a Comment