Search results
publicNumberFormatter::formatCurrency (float $amount, string $currency): string | false. Procedural style. numfmt_format_currency (NumberFormatter $formatter, float $amount, string $currency): string | false. Format the currency value according to the formatter rules.
- parseCurrency
The given example by Daniel returns false under PHP7.x,...
- getPattern
getPattern - NumberFormatter::formatCurrency - PHP
- setAttribute
setAttribute - NumberFormatter::formatCurrency - PHP
- getErrorMessage
getErrorMessage - NumberFormatter::formatCurrency - PHP
- getTextAttribute
getTextAttribute - NumberFormatter::formatCurrency - PHP
- getLocale
getLocale - NumberFormatter::formatCurrency - PHP
- getSymbol
getSymbol - NumberFormatter::formatCurrency - PHP
- setTextAttribute
setTextAttribute - NumberFormatter::formatCurrency - PHP
- parseCurrency
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 ().
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.
numfmt_format_currency (NumberFormatter $formatter, float $amount, string $currency): string | false Format the currency value according to the formatter rules. Parameters
If you want to use the intl extension and the NumberFormatter class, you can go like ... $formatter = new NumberFormatter ('en_GB', NumberFormatter::DECIMAL); $formatter->setAttribute (NumberFormatter::MIN_FRACTION_DIGITS, 2); var_dump ($formatter->format (23)); // string (5) "23.00".
public NumberFormatter::formatCurrency ( float $value , string $currency ) : string|false. Procedural style. numfmt_format_currency ( NumberFormatter $fmt , float $value , string $currency ) : string|false. Format the currency value according to the formatter rules.
Format the currency value according to the formatter rules. Parameters: fmt. NumberFormatter object. value. The numeric currency value. currency. The 3-letter ISO 4217 currency code indicating the currency to use. Returns: String representing the formatted currency value. Examples: numfmt_format_currency () example. OO example. See also: