User:Kaldari/Task 1

Let's say that for our annual fundraiser we want to use currency conversion rates that are periodically updated automatically rather than having to update them by hand. In order to do this, we sign up for a 3rd party service that provides us with daily conversion rates for the currencies that we support. The service is a simple API that outputs XML when called with the URL http://toolserver.org/~kaldari/rates.xml.

First, define a mySQL table that can store this data. You don't actually have to set up the table anywhere, just create an SQL file that contains the CREATE statement for the table.

Next, construct a PHP class that can handle all of the following tasks:


 * 1) Retrieving the data from the API (you can assume this will be triggered by a cron job)
 * 2) Parsing the data
 * 3) Storing the data in your mySQL table
 * 4) Given an amount of a foreign currency, convert it into the equivalent in US dollars. For example:
 * input: 'JPY 5000'
 * output: 'USD 65.63'
 * 1) Given an array of amounts in foreign currencies, return an array of US equivalent amounts in the same order. For example:
 * input: array( 'JPY 5000', 'CZK 62.5' )
 * output: array( 'USD 65.63', 'USD 3.27' )
 * (This can be a separate function from #4.)

Your submitted solution should contain 2 files:


 * a PHP file that defines the 'CurrencyConverter' class
 * an SQL file that creates the 'exchange_rates' mySQL table

Code checked into github is ideal.