Re: Currency Exchange Database?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux