Posts Get Currency Exchange Rate
Post
Cancel

Get Currency Exchange Rate

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
//http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html
//the file is updated daily between 2.15 p.m. and 3.00 p.m. CET

$XMLContent=file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"); 
    foreach($XMLContent as $line){ 
        if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){ 
            if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){ 
                //Output the value of 1EUR for a currency code 
                echo'1€='.$rate[1].' '.$currencyCode[1].'  
'; 
            } 
        } 
} 
?>

origin - http://www.pipiscrew.com/?p=1326 php-get-currency-exchange-rate

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags