array CCurrencyLang::GetCurrencyFormat( string currency, string lang = LANGUAGE_ID );
The method GetCurrencyFormat returns an array of the language dependent parameters of the specified currency for the specified language.
The method is similar to CCurrencyLang::GetByID except the fact that the CCurrencyLang::GetCurrencyFormat result is cached. Therefore, the repeated calls with the same currency identifier and language ID within the same page does not incur extra queries to the database.
Parameter | Description |
---|---|
currency | Identifier of currency whose language dependent parameters are required. |
lang | The ID of the language for which the parameters are to be returned. |
Associated array containing the following keys.
Key | Description |
---|---|
CURRENCY | The three character currency code. |
LID | The language ID. |
FORMAT_STRING | Format string used to display amounts of this currency in LID. |
FULL_NAME | Full name of the currency. |
DEC_POINT | Symbol used as a decimal point when displaying amounts. |
THOUSANDS_SEP | Symbol used as thousands separator when displaying amounts. |
DECIMALS | Number of digits in the fractional part of an amount when displaying amounts. |
<? function MyFormatCurrency($fSum, $strCurrency) { if (!isset($fSum) || strlen($fSum)<=0) return ""; $arCurFormat = CCurrencyLang::GetCurrencyFormat($strCurrency); if (!isset($arCurFormat["DECIMALS"])) $arCurFormat["DECIMALS"] = 2; $arCurFormat["DECIMALS"] = IntVal($arCurFormat["DECIMALS"]); if (!isset($arCurFormat["DEC_POINT"])) $arCurFormat["DEC_POINT"] = "."; if (!isset($arCurFormat["THOUSANDS_SEP"])) $arCurFormat["THOUSANDS_SEP"] = "\\"."xA0"; $tmpTHOUSANDS_SEP = $arCurFormat["THOUSANDS_SEP"]; eval("\$tmpTHOUSANDS_SEP = \"$tmpTHOUSANDS_SEP\";"); $arCurFormat["THOUSANDS_SEP"] = $tmpTHOUSANDS_SEP; if (!isset($arCurFormat["FORMAT_STRING"])) $arCurFormat["FORMAT_STRING"] = "#"; $num = number_format($fSum, $arCurFormat["DECIMALS"], $arCurFormat["DEC_POINT"], $arCurFormat["THOUSANDS_SEP"]); return str_replace("#", $num, $arCurFormat["FORMAT_STRING"]); } echo "The amount $11800.95 in the current language has the following format: "; echo MyFormatCurrency(11800.95, "USD"); ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |