Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

numfmt_set_text_attribute(3) [php man page]

NUMFMT_SET_TEXT_ATTRIBUTE(3)						 1					      NUMFMT_SET_TEXT_ATTRIBUTE(3)

NumberFormatter::setTextAttribute - Set a text attribute

	Object oriented style

SYNOPSIS
public bool NumberFormatter::setTextAttribute (int $attr, string $value) DESCRIPTION
Procedural style bool numfmt_set_text_attribute (NumberFormatter $fmt, int $attr, string $value) Set a text attribute associated with the formatter. An example of a text attribute is the suffix for positive numbers. If the formatter does not understand the attribute, U_UNSUPPORTED_ERROR error is produced. Rule-based formatters only understand NumberFormat- ter::DEFAULT_RULESET and NumberFormatter::PUBLIC_RULESETS. PARAMETERS
o $fmt -NumberFormatter object. o $attr - Attribute specifier - one of the text attribute constants. o $value - Text for the attribute value. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 numfmt_set_text_attribute(3) example <?php $fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL ); echo "Prefix: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)." "; echo numfmt_format($fmt, -1234567.891234567890000)." "; numfmt_set_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX, "MINUS"); echo "Prefix: ".numfmt_get_text_attribute($fmt, NumberFormatter::NEGATIVE_PREFIX)." "; echo numfmt_format($fmt, -1234567.891234567890000)." "; ?> Example #2 OO example <?php $fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL ); echo "Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)." "; echo $fmt->format(-1234567.891234567890000)." "; $fmt->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX, "MINUS"); echo "Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)." "; echo $fmt->format(-1234567.891234567890000)." "; ?> The above example will output: Prefix: - -1.234.567,891 Prefix: MINUS MINUS1.234.567,891 SEE ALSO
numfmt_get_error_code(3), numfmt_get_text_attribute(3), numfmt_set_attribute(3). PHP Documentation Group NUMFMT_SET_TEXT_ATTRIBUTE(3)

Check Out this Related Man Page

NUMFMT_GET_ATTRIBUTE(3) 						 1						   NUMFMT_GET_ATTRIBUTE(3)

NumberFormatter::getAttribute - Get an attribute

	Object oriented style

SYNOPSIS
public int NumberFormatter::getAttribute (int $attr) DESCRIPTION
Procedural style int numfmt_get_attribute (NumberFormatter $fmt, int $attr) Get 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. RETURN VALUES
Return attribute value on success, or FALSE on error. EXAMPLES
Example #1 numfmt_get_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_text_attribute(3), numfmt_set_attribute(3). PHP Documentation Group NUMFMT_GET_ATTRIBUTE(3)
Man Page