(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
Programs store and operate on numbers using a locale-independent binary representation. When displaying or printing a number it is converted to a locale-specific string. For example, the number 12345.67 is "12,345.67" in the US, "12 345,67" in France and "12.345,67" in Germany.
By invoking the methods provided by the NumberFormatter class, you can format numbers, currencies, and percentages according to the specified or default locale. NumberFormatter is locale-sensitive so you need to create a new NumberFormatter for each locale. NumberFormatter methods format primitive-type numbers, such as double and output the number as a locale-specific string.
For currencies you can use currency format type to create a formatter that returns a string with the formatted number and the appropriate currency sign. Of course, the NumberFormatter class is unaware of exchange rates so, the number output is the same regardless of the specified currency. This means that the same number has different monetary values depending on the currency locale. If the number is 9988776.65 the results will be:
In order to format percentages, create a locale-specific formatter with percentage format type. With this formatter, a decimal fraction such as 0.75 is displayed as 75%.
For more complex formatting, like spelled-out numbers, the rule-based number formatters are used.
These styles are used by the numfmt_create() to define the type of the formatter.
NumberFormatter::PATTERN_DECIMAL
     NumberFormatter::DECIMAL
     NumberFormatter::CURRENCY
     NumberFormatter::PERCENT
     NumberFormatter::SCIENTIFIC
     NumberFormatter::SPELLOUT
     NumberFormatter::ORDINAL
     NumberFormatter::DURATION
     NumberFormatter::PATTERN_RULEBASED
     NumberFormatter::CURRENCY_ACCOUNTING
     ($3.00) for negative currency amount
       instead of -$3.00. Available as of PHP 7.4.1 and ICU 53.
      
     NumberFormatter::DEFAULT_STYLE
     NumberFormatter::IGNORE
     These constants define how the numbers are parsed or formatted. They should be used as arguments to numfmt_format() and numfmt_parse().
NumberFormatter::TYPE_DEFAULT
     NumberFormatter::TYPE_INT32
     NumberFormatter::TYPE_INT64
     NumberFormatter::TYPE_DOUBLE
     NumberFormatter::TYPE_CURRENCY
     Number format attribute used by numfmt_get_attribute() and numfmt_set_attribute().
NumberFormatter::PARSE_INT_ONLY
     NumberFormatter::GROUPING_USED
     NumberFormatter::DECIMAL_ALWAYS_SHOWN
     NumberFormatter::MAX_INTEGER_DIGITS
     NumberFormatter::MIN_INTEGER_DIGITS
     NumberFormatter::INTEGER_DIGITS
     NumberFormatter::MAX_FRACTION_DIGITS
     NumberFormatter::MIN_FRACTION_DIGITS
     NumberFormatter::FRACTION_DIGITS
     NumberFormatter::MULTIPLIER
     NumberFormatter::GROUPING_SIZE
     NumberFormatter::ROUNDING_MODE
     NumberFormatter::ROUNDING_INCREMENT
     NumberFormatter::FORMAT_WIDTH
     NumberFormatter::PADDING_POSITION
     NumberFormatter::SECONDARY_GROUPING_SIZE
     NumberFormatter::SIGNIFICANT_DIGITS_USED
     NumberFormatter::MIN_SIGNIFICANT_DIGITS
     NumberFormatter::MAX_SIGNIFICANT_DIGITS
     NumberFormatter::LENIENT_PARSE
     Number format text attribute used by numfmt_get_text_attribute() and numfmt_set_text_attribute().
NumberFormatter::POSITIVE_PREFIX
     NumberFormatter::POSITIVE_SUFFIX
     NumberFormatter::NEGATIVE_PREFIX
     NumberFormatter::NEGATIVE_SUFFIX
     NumberFormatter::PADDING_CHARACTER
     NumberFormatter::CURRENCY_CODE
     NumberFormatter::DEFAULT_RULESET
     NumberFormatter::PUBLIC_RULESETS
     Number format symbols used by numfmt_get_symbol() and numfmt_set_symbol().
NumberFormatter::DECIMAL_SEPARATOR_SYMBOL
     NumberFormatter::GROUPING_SEPARATOR_SYMBOL
     NumberFormatter::PATTERN_SEPARATOR_SYMBOL
     NumberFormatter::PERCENT_SYMBOL
     NumberFormatter::ZERO_DIGIT_SYMBOL
     NumberFormatter::DIGIT_SYMBOL
     NumberFormatter::MINUS_SIGN_SYMBOL
     NumberFormatter::PLUS_SIGN_SYMBOL
     NumberFormatter::CURRENCY_SYMBOL
     NumberFormatter::INTL_CURRENCY_SYMBOL
     NumberFormatter::MONETARY_SEPARATOR_SYMBOL
    NumberFormatter::EXPONENTIAL_SYMBOL
     NumberFormatter::PERMILL_SYMBOL
     NumberFormatter::PAD_ESCAPE_SYMBOL
     NumberFormatter::INFINITY_SYMBOL
     NumberFormatter::NAN_SYMBOL
     NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL
     NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL
     
   Rounding mode values used by numfmt_get_attribute()
   and numfmt_set_attribute() with
   NumberFormatter::ROUNDING_MODE attribute.
   
NumberFormatter::ROUND_CEILING
     NumberFormatter::ROUND_DOWN
     NumberFormatter::ROUND_FLOOR
     NumberFormatter::ROUND_HALFDOWN
     NumberFormatter::ROUND_HALFEVEN
     NumberFormatter::ROUND_HALFUP
     NumberFormatter::ROUND_UP
     
   Pad position values used by numfmt_get_attribute()
   and numfmt_set_attribute() with
   NumberFormatter::PADDING_POSITION attribute.
   
NumberFormatter::PAD_AFTER_PREFIX
     NumberFormatter::PAD_AFTER_SUFFIX
     NumberFormatter::PAD_BEFORE_PREFIX
     NumberFormatter::PAD_BEFORE_SUFFIX