ICC.PHP International Currency Converter for Phorm The purpose of this module is to provide a function for converting between various international currencies. The conversion rates are drawn from the table posted daily at http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml by the European Central Bank. INSTALLATION To install this module, place the file icc.php in your plugins directory, and add the following line to the registry file registry.php: > setu1 icc.php USE When this plugin loads, it creates a function named ConvertCurrency: ConvertCurrency($Amount, $TargetCurrency, $BaseCurrency); $Amount is, of course, the amount you wish to convert. $BaseCurrency is the currency you wish to convert from, and $TargetCurrency is what you wish to convert to. $TargetCurrency is optional, and defaults to Euros; $BaseCurrency is optional, and defaults to US Dollars. Examples: $Euros = ConvertCurrency(5); // USD$5 to Euros $Yen = ConvertCurrency(5, "JPY"); // USD$5 to Japanese Yen $Yen = ConvertCurrency(5, "JPY", "EUR"); // 5 Euros to Japanese Yen You can specify more than one target currency if you wish. In this case the result returned will be an array keyed on the currency codes. For example: $Conversions = ConvertCurrency($EuroPrice, "JPY, USD", "EUR"); Converts whatever is in $EuroPrice to Japanese Yen and US Dollars. The US Dollar amount will be in $Conversions['USD'] and the Yen amount will be in $Conversions['JPY']. To reference these values in your templates, omit the single quotes in the array keys. For example: Price: {{EuroPrice}} Euros {{Conversions[USD]}} US Dollars {{Conversions[JPY]}} Japanese Yen DEVELOPER NOTE When it loads, ICC creates an array named $ICC_CurrencyTable. This is an associative array keyed on currency codes, with conversion rates as values. The conversion rates are based on the Euro, as extracted from the ECB URL mentioned above. If you have access to other rate information, you can use it to replace or extend ICC's array if you wish. Simply place your code before any calls to the ConvertCurrency() function. Bear in mind that the function assumes conversion rates based on the Euro. ICC also creates an array named $ICC_CurrencyNames. This again is an associative array keyed on currency codes. Each element is an associative array with keys "CTY" and "CUR", with values of country name and currency name, respectively. The currency codes are those in common usage, which in most cases, but not all, are the same as the ISO currency codes. Note that some currencies, such as Gold Ounces (XAU), do not have a CTY key. That's all there is to it! =========================== Copyright (c) 2002 Holotech Enterprises (phorm@holotech.net) You may freely distribute this program as-is, without modifications, as part of a valid Phorm distribution. If you are not sure whether you have a valid distribution, you can obtain one from http://www.phorm.com/. You may use this program freely, and modify it for your own purposes.