NUMFMT_CREATE(3) 1 NUMFMT_CREATE(3)
NumberFormatter::create - Create a number formatter
Object oriented style (method)
SYNOPSIS
publicstatic NumberFormatter NumberFormatter::create (string $locale, int $style, [string $pattern])
DESCRIPTION
Procedural style
NumberFormatter numfmt_create (string $locale, int $style, [string $pattern])
Object oriented style (constructor): NumberFormatter::__construct (string $locale, int $style, [string $pattern])
Creates a number formatter.
PARAMETERS
o $locale
- Locale in which the number would be formatted (locale name, e.g. en_CA).
o $style
- Style of the formatting, one of the format style constants. If NumberFormatter::PATTERN_DECIMAL or NumberFormatter::PAT-
TERN_RULEBASED is passed then the number format is opened using the given pattern, which must conform to the syntax described in
ICU DecimalFormat documentation or ICU RuleBasedNumberFormat documentation, respectively.
o $pattern
- Pattern string if the chosen style requires a pattern.
RETURN VALUES
Returns NumberFormatter object or FALSE on error.
EXAMPLES
Example #1
numfmt_create(3) example
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo numfmt_format($fmt, 1234567.891234567890000)."
";
$fmt = numfmt_create( 'it', NumberFormatter::SPELLOUT );
echo numfmt_format($fmt, 1142)."
";
?>
Example #2
numfmt_create(3) example
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo $fmt->format(1234567.891234567890000)."
";
$fmt = new NumberFormatter( 'it', NumberFormatter::SPELLOUT );
echo $fmt->format(1142)."
";
?>
The above example will output:
1.234.567,891
millicentoquarantadue
SEE ALSO
numfmt_format(3), numfmt_parse(3).
PHP Documentation Group NUMFMT_CREATE(3)