Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

numfmt_set_attribute(3) [php man page]

NUMFMT_SET_ATTRIBUTE(3) 						 1						   NUMFMT_SET_ATTRIBUTE(3)

NumberFormatter::setAttribute - Set an attribute

	Object oriented style

SYNOPSIS
public bool NumberFormatter::setAttribute (int $attr, int $value) DESCRIPTION
Procedural style bool numfmt_set_attribute (NumberFormatter $fmt, int $attr, int $value) Set a numeric attribute associated with the formatter. An example of a numeric attribute is the number of integer digits the formatter will produce. PARAMETERS
o $fmt -NumberFormatter object. o $attr - Attribute specifier - one of the numeric attribute constants. o $value - The attribute value. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 numfmt_set_attribute(3) example <?php $fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL ); echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)." "; echo numfmt_format($fmt, 1234567.891234567890000)." "; numfmt_set_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS, 2); echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)." "; echo numfmt_format($fmt, 1234567.891234567890000)." "; ?> Example #2 OO example <?php $fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL ); echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)." "; echo $fmt->format(1234567.891234567890000)." "; $fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 2); echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)." "; echo $fmt->format(1234567.891234567890000)." "; ?> The above example will output: Digits: 3 1.234.567,891 Digits: 2 1.234.567,89 SEE ALSO
numfmt_get_error_code(3), numfmt_get_attribute(3), numfmt_set_text_attribute(3). PHP Documentation Group NUMFMT_SET_ATTRIBUTE(3)

Check Out this Related Man Page

NUMFMT_GET_SYMBOL(3)							 1						      NUMFMT_GET_SYMBOL(3)

NumberFormatter::getSymbol - Get a symbol value

	Object oriented style

SYNOPSIS
public string NumberFormatter::getSymbol (int $attr) DESCRIPTION
Procedural style string numfmt_get_symbol (NumberFormatter $fmt, int $attr) Get a symbol associated with the formatter. The formatter uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters. PARAMETERS
o $fmt -NumberFormatter object. o $attr - Symbol specifier, one of the format symbol constants. RETURN VALUES
The symbol string or FALSE on error. EXAMPLES
Example #1 numfmt_get_symbol(3) example <?php $fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL ); echo "Sep: ".numfmt_get_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL)." "; echo numfmt_format($fmt, 1234567.891234567890000)." "; numfmt_set_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL, "*"); echo "Sep: ".numfmt_get_symbol($fmt, NumberFormatter::GROUPING_SEPARATOR_SYMBOL)." "; echo numfmt_format($fmt, 1234567.891234567890000)." "; ?> Example #2 OO example <?php $fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL ); echo "Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)." "; echo $fmt->format(1234567.891234567890000)." "; $fmt->setSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, "*"); echo "Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)." "; echo $fmt->format(1234567.891234567890000)." "; ?> The above example will output: Sep: . 1.234.567,891 Sep: * 1*234*567,891 SEE ALSO
numfmt_get_error_code(3), numfmt_set_symbol(3). PHP Documentation Group NUMFMT_GET_SYMBOL(3)
Man Page