1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<?php
//This is a PHP(4/5) script example on how eurofxref-daily.xml can be parsed
//Read eurofxref-daily.xml file in memory
//For this command you will need the config option allow_url_fopen=On (default)
$XMLContent=file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
//the file is updated daily between 2.15 p.m. and 3.00 p.m. CET
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€=<b>'.$rate[1].'</b> '.$currencyCode[1].' | ';
//--------------------------------------------------
//Here you can add your code for inserting
//$rate[1] and $currencyCode[1] into your database
//--------------------------------------------------
}
}
}
?> |
Partager