Documentation

CurrencyFormat

string
CurrencyFormat(
 float price,
 string currency
);

This function formats the price amount in accordance with formatting rules for the currency in the current language. With that, if the function is called in the administrative section, the cleaning of the template from tags and scripts will be additionally performed. If the function is called in the public section, then the HIDE_ZERO parameter will be used; it is responsible for concealment of nonsignificant zeros in the fractional part.

Note: it is recommended to use a new [link=869044]CurrencyFormat[/link] function of CCurrencyLang class instead of this deprecated function.

Function parameters

ParameterDescription
price Amount (sum amount), which must be formatted.
currency Currency, by which rules the formatting must be performed.

Returned values

Returns a formatted string.

Examples of use

<?
echo CurrencyFormat(11800.95, "USD");
?>
<?
// The format of price display can be set as follows

AddEventHandler("currency", "CurrencyFormat", "myFormat");

function myFormat($fSum, $strCurrency)
{
   return number_format ( $fSum, 2, '.', ' ' ).' US dollars.';
}

echo CurrencyFormat(1234.5678, 'USD');
?>


© «Bitrix24», 2001-2024
Up