NumberFormat class.
NumberFormat formats decimal numbers in any locale. The decimal number is formatted according to a particular pattern. These patterns can arise from the NumberFormatInfo object which is culturally sensitive. The NumberFormat class can be instantiated in many ways. E.g.
- //create a invariant number formatter.
- $formatter = new NumberFormat();
- //create a number format for the french language locale.
- $fr = new NumberFormat('fr');
- //create a number format base on a NumberFormatInfo instance $numberInfo.
- $format = new NumberFormat($numberInfo);
A normal decimal number can also be displayed as a currency or as a percentage. For example
Currency is formated using the localized currency pattern. For example to format the number as Japanese Yen:
For each culture, the symbol for each currency may be different.
- $ja = new NumberFormat('ja_JP');
- //Japanese currency pattern, and using Japanese Yen symbol
- $ja->format(123.14,'c','JPY'); //�?123 (Yen 123)
Located in /I18N/core/NumberFormat.php (line 74)
The DateTimeFormatInfo, containing culture specific patterns and names.
Create a new number format instance. The constructor can be instantiated with a string that represent a culture/locale. Similarly, passing a CultureInfo or NumberFormatInfo instance will instantiated a instance for that particular culture.
For the number for a certain pattern. The valid patterns are 'c', 'd', 'e', 'p' or a custom pattern, such as "#.000" for 3 decimal places.
Format the decimal places.
For the integer, perform groupings and string padding.
Set the pattern to format against. The default patterns are retrieved from the NumberFormatInfo instance.
Documentation generated on Sun, 04 Jun 2006 18:58:31 -0400 by phpDocumentor 1.3.0RC4