Re: [PHP] Currency Exchange Database?



Andy B. wrote:
You could have a look at the Euro foreign exchange reference rates rom the
European Central Bank.

They also provide a regularly updated XML file:

http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html



/* pass this func a 3 letter currency code */
function getCurrentRate($curID)
{
static $rates;

if (is_null($rates)) {
$rates = array('EUR' => 1.0);

$doc = new DomDocument;
$doc->load( 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml' );

foreach ($doc->getElementsByTagname("Cube") as $node) {
$c = $node->getAttribute("currency") and
$rates[$c] = 1 / $node->getAttribute("rate");
}
}

return (isset($rates[$curID]) ? $rates[$curID] : 0.0);
}


----
Andy

-----Original Message-----
From: Tom Ray [Lists] [mailto:lists@xxxxxxxxxxxxxxxx]
Sent: Friday, June 29, 2007 02:45
To: php-general@xxxxxxxxxxxxx
Subject: [PHP] Currency Exchange Database?

I have a client that's looking to do auto conversions of currency on
their reservation payment form. No big deal, I can that part down.
However, exchange rates change on a minute to minute basis and they want
the program to automatically know the current rates. Is there an online
database or a way I can tap into a database that has that information?

Any help would be appreciated.

Thanks.

.



Relevant Pages

  • Re: DBIx::XML::DataLoader
    ... Is there a package or utility that can read an XML file of the sort I ... The dbinfo specifies the login ... credentials to the database, and the database. ... And, I have no idea what XPATH is, let alone what to do with it. ...
    (comp.lang.perl.misc)
  • Re: XML parser and writer
    ... XStream, Castor, JAXB come to mind. ... why not some database technology? ... an advanced user can edit the XML file directly at ...
    (comp.lang.java.programmer)
  • Re: XML parser and writer
    ... them on a calendar. ... set for it and I was thinking of storing all the data in an XML file. ... why not some database technology? ... Tasklist the DOM would quickly become unwieldy especially if you have any ...
    (comp.lang.java.programmer)
  • RE: Backup Log Links dont work in Server Management Console
    ... Check the database connection information and make sure that the database ... "Rob Currier" wrote: ... It created a new xml file with the same name. ... >> for the backup and last backup is correct. ...
    (microsoft.public.windows.server.sbs)
  • DBIx::XML::DataLoader
    ... Is there a package or utility that can read an XML file of the sort I ... credentials to the database, and the database. ... Also obviously not all columns in the database are keys or indeces. ...
    (comp.lang.perl.misc)