php8.5
Home/ Manual/ reference / intl/ Format Types

Format Types

These styles are used by the numfmt_create to define the type of the formatter. NumberFormatter::PATTERN_DECIMALintDecimal format defined by patternNumberFormatter::DECIMALintDecimal formatNumberFormatter::DECIMAL_COMPACT_SHORTintDecimal format expressed using compact notation (short form), e.g. "23K", "45B". Available as of PHP 8.5.0 and ICU 56.NumberFormatter::DECIMAL_COMPACT_LONGintDecimal format expressed using compact notation (long form), e.g. "23 thousand", "45 billion". Available as of PHP 8.5.0 and ICU 56.NumberFormatter::CURRENCYintCurrency formatNumberFormatter::CURRENCY_ISOintISO currency format (e.g., "USD1.00"). Available as of PHP 8.5.0.NumberFormatter::CURRENCY_PLURALintPluralized currency format (e.g., "1.00 US dollar" and "3.00 US dollars"). Available as of PHP 8.5.0.NumberFormatter::CASH_CURRENCYintCurrency symbol given CASH usage, e.g., "NT$3" instead of "NT$3.23". Available as of PHP 8.5.0 and ICU 54NumberFormatter::CURRENCY_STANDARDintCurrency symbol, e.g., "$1.00", using non-accounting style for negative values (e.g. minus sign). Available as of PHP 8.5.0 and ICU 56.NumberFormatter::PERCENTintPercent formatNumberFormatter::SCIENTIFICintScientific formatNumberFormatter::SPELLOUTintSpellout rule-based formatNumberFormatter::ORDINALintOrdinal rule-based formatNumberFormatter::DURATIONintDuration rule-based formatNumberFormatter::PATTERN_RULEBASEDintRule-based format defined by patternNumberFormatter::CURRENCY_ACCOUNTINGint Currency format for accounting, e.g., ($3.00) for negative currency amount instead of -$3.00. Available as of PHP 7.4.1 and ICU 53. NumberFormatter::DEFAULT_STYLEintDefault format for the localeNumberFormatter::IGNOREintAlias for PATTERN_DECIMAL

Predefined Constants

Format Types

These styles are used by the numfmt_create() to define the type of the formatter.

NumberFormatter::PATTERN_DECIMALint

Decimal format defined by pattern

NumberFormatter::DECIMALint

Decimal format

NumberFormatter::DECIMAL_COMPACT_SHORTint

Decimal format expressed using compact notation (short form), e.g. "23K", "45B". Available as of PHP 8.5.0 and ICU 56.

NumberFormatter::DECIMAL_COMPACT_LONGint

Decimal format expressed using compact notation (long form), e.g. "23 thousand", "45 billion". Available as of PHP 8.5.0 and ICU 56.

NumberFormatter::CURRENCYint

Currency format

NumberFormatter::CURRENCY_ISOint

ISO currency format (e.g., "USD1.00"). Available as of PHP 8.5.0.

NumberFormatter::CURRENCY_PLURALint

Pluralized currency format (e.g., "1.00 US dollar" and "3.00 US dollars"). Available as of PHP 8.5.0.

NumberFormatter::CASH_CURRENCYint

Currency symbol given CASH usage, e.g., "NT$3" instead of "NT$3.23". Available as of PHP 8.5.0 and ICU 54

NumberFormatter::CURRENCY_STANDARDint

Currency symbol, e.g., "$1.00", using non-accounting style for negative values (e.g. minus sign). Available as of PHP 8.5.0 and ICU 56.

NumberFormatter::PERCENTint

Percent format

NumberFormatter::SCIENTIFICint

Scientific format

NumberFormatter::SPELLOUTint

Spellout rule-based format

NumberFormatter::ORDINALint

Ordinal rule-based format

NumberFormatter::DURATIONint

Duration rule-based format

NumberFormatter::PATTERN_RULEBASEDint

Rule-based format defined by pattern

NumberFormatter::CURRENCY_ACCOUNTINGint

Currency format for accounting, e.g., ($3.00) for negative currency amount instead of -$3.00. Available as of PHP 7.4.1 and ICU 53.

NumberFormatter::DEFAULT_STYLEint

Default format for the locale

NumberFormatter::IGNOREint

Alias for PATTERN_DECIMAL

Number Format Specifiers

These constants define how the numbers are parsed or formatted. They should be used as arguments to numfmt_format() and numfmt_parse().

NumberFormatter::TYPE_DEFAULTint

Derive the type from variable type

NumberFormatter::TYPE_INT32int

Format/parse as 32-bit integer

NumberFormatter::TYPE_INT64int

Format/parse as 64-bit integer

NumberFormatter::TYPE_DOUBLEint

Format/parse as floating point value

NumberFormatter::TYPE_CURRENCYint

Format/parse as currency value. Deprecated as of PHP 8.3.0

Number Format Attributes

Number format attribute used by numfmt_get_attribute() and numfmt_set_attribute().

NumberFormatter::PARSE_INT_ONLYint

Parse integers only.

NumberFormatter::GROUPING_USEDint

Use grouping separator.

NumberFormatter::DECIMAL_ALWAYS_SHOWNint

Always show decimal point.

NumberFormatter::MAX_INTEGER_DIGITSint

Maximum integer digits.

NumberFormatter::MIN_INTEGER_DIGITSint

Minimum integer digits.

NumberFormatter::INTEGER_DIGITSint

Integer digits.

NumberFormatter::MAX_FRACTION_DIGITSint

Maximum fraction digits.

NumberFormatter::MIN_FRACTION_DIGITSint

Minimum fraction digits.

NumberFormatter::FRACTION_DIGITSint

Fraction digits.

NumberFormatter::MULTIPLIERint

Multiplier.

NumberFormatter::GROUPING_SIZEint

Grouping size.

NumberFormatter::ROUNDING_MODEint

Rounding Mode.

NumberFormatter::ROUNDING_INCREMENTint

Rounding increment.

NumberFormatter::FORMAT_WIDTHint

The width to which the output of format() is padded.

NumberFormatter::PADDING_POSITIONint

The position at which padding will take place. See pad position constants for possible argument values.

NumberFormatter::SECONDARY_GROUPING_SIZEint

Secondary grouping size.

NumberFormatter::SIGNIFICANT_DIGITS_USEDint

Use significant digits.

NumberFormatter::MIN_SIGNIFICANT_DIGITSint

Minimum significant digits.

NumberFormatter::MAX_SIGNIFICANT_DIGITSint

Maximum significant digits.

NumberFormatter::LENIENT_PARSEint

Lenient parse mode used by rule-based formats.

Number Format Text Attributes

Number format text attribute used by numfmt_get_text_attribute() and numfmt_set_text_attribute().

NumberFormatter::POSITIVE_PREFIXint

Positive prefix.

NumberFormatter::POSITIVE_SUFFIXint

Positive suffix.

NumberFormatter::NEGATIVE_PREFIXint

Negative prefix.

NumberFormatter::NEGATIVE_SUFFIXint

Negative suffix.

NumberFormatter::PADDING_CHARACTERint

The character used to pad to the format width.

NumberFormatter::CURRENCY_CODEint

The ISO currency code.

NumberFormatter::DEFAULT_RULESETint

The default rule set. This is only available with rule-based formatters.

NumberFormatter::PUBLIC_RULESETSint

The public rule sets. This is only available with rule-based formatters. This is a read-only attribute. The public rulesets are returned as a single string, with each ruleset name delimited by ';' (semicolon).

Symbol Format Specifiers

Number format symbols used by numfmt_get_symbol() and numfmt_set_symbol().

NumberFormatter::DECIMAL_SEPARATOR_SYMBOLint

The decimal separator.

NumberFormatter::GROUPING_SEPARATOR_SYMBOLint

The grouping separator.

NumberFormatter::PATTERN_SEPARATOR_SYMBOLint

The pattern separator.

NumberFormatter::PERCENT_SYMBOLint

The percent sign.

NumberFormatter::ZERO_DIGIT_SYMBOLint

Zero.

NumberFormatter::DIGIT_SYMBOLint

Character representing a digit in the pattern.

NumberFormatter::MINUS_SIGN_SYMBOLint

The minus sign.

NumberFormatter::PLUS_SIGN_SYMBOLint

The plus sign.

NumberFormatter::CURRENCY_SYMBOLint

The currency symbol.

NumberFormatter::INTL_CURRENCY_SYMBOLint

The international currency symbol.

NumberFormatter::MONETARY_SEPARATOR_SYMBOLint

The monetary separator.

NumberFormatter::EXPONENTIAL_SYMBOLint

The exponential symbol.

NumberFormatter::PERMILL_SYMBOLint

Per mill symbol.

NumberFormatter::PAD_ESCAPE_SYMBOLint

Escape padding character.

NumberFormatter::INFINITY_SYMBOLint

Infinity symbol.

NumberFormatter::NAN_SYMBOLint

Not-a-number symbol.

NumberFormatter::SIGNIFICANT_DIGIT_SYMBOLint

Significant digit symbol.

NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOLint

The monetary grouping separator.

Rounding Modes

Rounding mode values used by numfmt_get_attribute() and numfmt_set_attribute() with NumberFormatter::ROUNDING_MODE attribute.

NumberFormatter::ROUND_AWAY_FROM_ZERO

Alias NumberFormatter::ROUND_UP.

NumberFormatter::ROUND_CEILINGint

Rounding mode to round towards positive infinity.

NumberFormatter::ROUND_DOWNint

Rounding mode to round towards zero.

NumberFormatter::ROUND_FLOORint

Rounding mode to round towards negative infinity.

NumberFormatter::ROUND_HALFDOWNint

Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.

NumberFormatter::ROUND_HALFEVENint

Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.

NumberFormatter::ROUND_HALFODD

Rounding mode to round towards the "odd neighbor".

NumberFormatter::ROUND_HALFUPint

Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.

NumberFormatter::ROUND_TOWARD_ZERO

Alias NumberFormatter::ROUND_DOWN.

NumberFormatter::ROUND_UPint

Rounding mode to round away from zero.

Padding Specifiers

Pad position values used by numfmt_get_attribute() and numfmt_set_attribute() with NumberFormatter::PADDING_POSITION attribute.

NumberFormatter::PAD_AFTER_PREFIXint

Pad characters inserted after the prefix.

NumberFormatter::PAD_AFTER_SUFFIXint

Pad characters inserted after the suffix.

NumberFormatter::PAD_BEFORE_PREFIXint

Pad characters inserted before the prefix.

NumberFormatter::PAD_BEFORE_SUFFIXint

Pad characters inserted before the suffix.

Source: reference/intl/numberformatter-constants.xml · from the official PHP manual (php/doc-en)