# NumberFormatter::formatCurrency

# numfmt_format_currency

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

NumberFormatter::formatCurrency -- numfmt_format_currency — Format a currency value

### Beschreibung

Objektorientierter Stil

public NumberFormatter::formatCurrency(float `$amount`, string `$currency`): string|false

Prozeduraler Stil

numfmt_format_currency(NumberFormatter `$formatter`, float `$amount`, string `$currency`): string|false

Format the currency value according to the formatter rules.

### Parameter-Liste

`formatter`

  NumberFormatter object.

`amount`

  The numeric currency value.

`currency`

  The 3-letter ISO 4217 currency code indicating the currency to use.

### Rückgabewerte

String representing the formatted currency value, Bei einem Fehler wird `false` zurückgegeben..

### Beispiele

Beispiel #1 numfmt_format_currency() example

`<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::CURRENCY );
echo numfmt_format_currency($fmt, 1234567.891234567890000, "EUR")."\n";
echo numfmt_format_currency($fmt, 1234567.891234567890000, "RUR")."\n";
$fmt = numfmt_create( 'ru_RU', NumberFormatter::CURRENCY );
echo numfmt_format_currency($fmt, 1234567.891234567890000, "EUR")."\n";
echo numfmt_format_currency($fmt, 1234567.891234567890000, "RUR")."\n";
?>`

Beispiel #2 OO example

`<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY );
echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n";
echo $fmt->formatCurrency(1234567.891234567890000, "RUR")."\n";
$fmt = new NumberFormatter( 'ru_RU', NumberFormatter::CURRENCY );
echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n";
echo $fmt->formatCurrency(1234567.891234567890000, "RUR")."\n";
?>`

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

    1.234.567,89 €
    1.234.567,89 RUR
    1 234 567,89€
    1 234 567,89р.

### Anmerkungen

> Hinweis:

> Formats achievable by this method of formatting cannot fully use the possibilities of underlying ICU library, such as to format currency with narrow currency symbol.

> To fully utilize them use msgfmt_format_message().

### Siehe auch

- numfmt_get_error_code() - Get formatter's last error code
- numfmt_format() - Format a number
- numfmt_parse_currency() - Parse a currency number
- msgfmt_format_message() - Quick format message

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open