MIOLO26
|
Handles the formatting of monetary amounts according to different formatting styles.
An amount can be formatted according to a given style, or to the style for a given ISO 4217 currency code (eg. AUD).
The class can also be used to validate currency amounts according to a particular formatting style, and to convert a formatted string to a double amount.
Example usage:
$cf = new CurrencyFormatter();
$formattedAmount = $cf->format(1234.56, "ESP"); // $formattedAmount is now == "1.234,56 Ptas"
$formattedAmount = $cf->format(1234.56, "GBP"); // $formattedAmount is now == "£1.234,56"
$decimal = $cf->toDecimal("1.234,56 Ptas"); // $decimal is now == 1234.56;
$isValid = $cf->validate("1.234,56 Ptas", "ESP"); // $isValid is now == true $isValid = $cf->validate("1.234,56", "ESP"); // $isValid is now == true $isValid = $cf->validate("1,234.56 Ptas", "ESP"); // $isValid is now == false