AppTools.com
Web Development Tools that Enlighten
Currency Exchange Rates with PHP & XML
So you developed this fantastic business plan. You've started your business
and you've got a web site. You're selling your product or service on the web.
Everything is going great! All of a sudden, you are doing business all over
the world. Your customers are now in different countries, using different currencies.
How are they going to know how much something is going to cost them in their
currency? Using PHP and its XML parsing capabilities, you can provide prices
in many different currencies.
Okay, before we start, let's talk about some boring legal stuff. The reference rates below obtained from the European Central Bank and are based on the regular daily concertation procedure between central banks within and outside the European System of Central Banks, which normally takes place at 2.15 p.m. ECB time (CET).
The below listed currency exchange rates are examples that are updated only once daily (Monday through Friday except holidays) and believed to be correct as of the date indicated. However, as examples, these rates should not be assumed to be entirely accurate and should not be used in financial transactions. The chart below, lists the equivalent amounts that correspond to one United States Dollar.
| Currency | ID | Rate |
|---|---|---|
| Australia Dollar | AUD | 1.0316 |
| Brazil Reai | BRL | 2.0458 |
| Bulgaria Leva | BGN | 1.5116 |
| Canada Dollar | CAD | 1.0332 |
| China Yuan Renminbi | CNY | 6.1319 |
| Croatia Kuna | HRK | 5.8494 |
| Czech Republic Koruny | CZK | 20.0889 |
| Denmark Kroner | DKK | 5.7608 |
| Euro | EUR | 0.7729 |
| Hong Kong Dollar | HKD | 7.7632 |
| Hungary Forint | HUF | 224.4377 |
| India Rupee | INR | 55.7462 |
| Indonesia Rupiahs | IDR | 9,796.14 |
| Israel New Shekel | ILS | 3.6956 |
| Japan Yen | JPY | 101.4375 |
| Latvian Lat | LVL | 0.5412 |
| Lithuanian Lita | LTL | 2.6685 |
| Malaysia Ringgit | MYR | 3.0345 |
| Mexico Peso | MXN | 12.4450 |
| New Zealand Dollar | NZD | 1.2337 |
| Norway Kroner | NOK | 5.8185 |
| Philippines Peso | PHP | 41.7042 |
| Poland Zlotych | PLN | 3.2446 |
| Romania New Leu | RON | 3.3658 |
| Russia Ruble | RUB | 31.3285 |
| Singapore Dollar | SGD | 1.2644 |
| South Africa Rand | ZAR | 9.5621 |
| South Korea Won | KRW | 1,126.97 |
| Sweden Kronor | SEK | 6.6450 |
| Switzerland Franc | CHF | 0.9634 |
| Thailand Baht | THB | 29.9196 |
| Turkey New Lira | TRY | 1.8481 |
| United Kingdom Pound | GBP | 0.6623 |
| United States Dollar | USD | 1.0000 |
So What?
All right, showing a chart like that is a neat trick, but so what? How does that help you as a web developer? Let's say, for example, you are in the United States and your product sells for $24.95 in U.S. dollars. How much is that in U. K. pounds, or in Euros? Easy! It would be £16.52, or €19.28. Oh, just in case you were curious, it would be 25.78 Canadian dollars, or ¥2,530.87 in Japanese yen.
Note that all the figures in the preceding paragraph are calculated live, based on the above exchange rates! Are you beginning to see the possibilities? Let's say you're in Hong Kong. You sell your product for 200 Hong Kong dollars. What would the price be for someone in the United States? $25.76.
If I have your attention, please read on to see how to perform currency conversions