Grow your CSS skills. Land your dream job.

Currency Conversion using PHP

  • # December 30, 2009 at 3:23 am

    I am working on a shopping cart website project, which is still in development phase.
    I want to display the rates of the products in INR(Indian Rupees) and USD(US Dollars).
    Can someone help me with a php code for doing the live currency conversion.
    I want to know how can I collect the live currency values in a php variable to do the conversion.

    For example: If I go to the link http://www.xe.com/ucc/convert.cgi?From= … R&Amount=1
    Here I can get the live rate for US dollars to INR conversion. As It is shown in the picture below.
    [attachment=0]a.JPG[/attachment]

    In the picture it is also shown that 1 INR = 0.0214083 USD (This is the live current value).
    Is there any way I can collect the live current value of the currency in a variable?
    Please help me in resolving this issue, or please point me to the right direction.

    # January 1, 2010 at 7:53 pm

    You can’t specifically get the conversion rates from XE using just PHP unless you pay for their feed, which is $540. I had originally thought you may be able to use curl(), however it is against their terms of service and so I doubt anyone would be help you on this forum.

    There are numerous other sites that will give you free conversion XML files which you can then parse with SimpleXML(). For example, Euro conversion can be found here http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".