hi, i want php script for currency conversion help me please.....
+1
A:
Taken from http://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html#dev
How to parse the data
This is just an example
<?php
//This is a PHP (4/5) script example on how eurofxref-daily.xml can be parsed
//Read eurofxref-daily.xml file in memory
$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 (ereg("currency='([[:alpha:]]+)'",$line,$currencyCode)) {
if (ereg("rate='([[:graph:]]+)'",$line,$rate)) {
//Output the value of 1 EUR for a currency code
echo '1 € = '.$rate[1].' '.$currencyCode[1].'<br />';
//--------------------------------------------------
// Here you can add your code for inserting
// $rate[1] and $currencyCode[1] into your database
//--------------------------------------------------
}
}
}
?>
Not the best of scripts, but then again, you just asked for gimme-teh-codez.
Gordon
2010-04-14 06:57:08
A:
you can calculate exchange rates quite simply like:
$from = "GBP";
$to = "USD";
$url = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency='.$from.'&ToCurrency='.$to;
$rate = simplexml_load_file($url);
echo 'Rate from '.$from.' to '.$to.' is: '.$rate[0];
seengee
2010-04-14 11:58:06