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:[EMAIL PROTECTED] 
> 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.
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to