Re: Currency Exchange Database?
| From: | Jochem Maas | Date: | Fri, 29 Jun 2007 06:51:32 +0000 |
| Subject: | Re: Currency Exchange Database? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257940@lists.php.net to get a copy of this message | ||
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@blazestudios.com]
> Sent: Friday, June 29, 2007 02:45
> To: php-general@lists.php.net
> 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.
>