|
Posted by Kimmo Laine on 11/18/52 11:43
<meenasamy@hotmail.com> wrote in message
news:1143533587.102091.31550@v46g2000cwv.googlegroups.com...
> Hi all, i need to create a function that takes three parameters(
> Original currency, needed currency, amount) i need to convert from the
> original currency to the needed currency the amount and return the new
> amount in the needed currency, I need this function to work real time
> (obtaining real time currency exchange rates), any ideas???
Currency conversion rates are usually given in reference to another
currency. To convert 1 euro to us dollars, I'd need to know either how many
dollars one euro is, or how many euros one dollar is. Google currency
convertor gives a rate of 1 Euro = 1.20300 U.S. dollars. That means with 1
euro I can buy 1 dollar and 20 cents. Now, if I want to convert a random
amount of euros to dollars, for example 20 euros, I'd just multiply 20 euros
with the rate 1.20300 and presto, I get 24.06 dollars. That's just simple
math. The hard part is obtaning the rate.
As you might've guessed already that php does not have a built in currency
exchange rate function that would real-time fetch the currencies. How to
obtain the currency rates, real-time? Well, Google is your friend as always
(in fact it has a built-in currency converter but they do not gurantee
accuracy), you can search for methods of obtaning the exhange rates. Getting
them real-time requires communication with a third party service. I found
for an example a website called xmethods ( http://www.xmethods.com/ ) that
lists a wide range of services and among these, php libraries for obtaning
currency exchange rates via communicating with a third party server.
HTH.
Ps. I hope the "urgent" was just a joke because I'd estimate researching the
methods and implementing it takes time...
--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviφ
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
[Back to original message]
|