![]() | Welcome to Islandnet.com Locally owned and operated since 1993 |
| Create an Account • Pricing & Features • Domain Registration • Customer Sites • Help & Info | |
Sunday May 18 2008 | |
Web Gadget: CurrencyDescriptionThis gadget does nothing by itself, but it provides you with up-to-date currency exchange rates and a utility function to convert value from one currency to another. It allows you to add currency calculations to your own PHP programs without having to worry about maintaining exchange rates.The exchange rate data is pulled from Canadian Banks several times daily.
Usage Summary@include "gadget:currency"; DetailsThis gadget provides you with a global array named $CURRENCY_data that contains the actual exchange rates and currency names, as well as a utility function named CURRENCY_convert.The $CURRENCY_data array uses the ISO 4217 currency codes as a key and contains two fields for each currency: 'name' and 'rate'. The rate is relative to the Canadian dollar. For example, the following PHP code:
produces the following output:
The CURRENCY_convert function takes three parameters: the amount to convert, the ISO code of the source currency, and the ISO code of the destination currency. For example, the following code will convert $150 in Canadian dollars into US funds:
Examples:SimpleCurrencyConvertor (view source) |