Just sharing this currency converter script that I used on my website.
Feel free to modify it based on your needs.
It uses finance.yahoo.com conversion table.
<?php
$from = 'USD'; //US Dollar
$to = 'SAR'; //to Philippine Peso
$url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s='. $from . $to .'=X';
$handle = @fopen($url, 'r');
if ($handle) {
$result = fgets($handle, 4096);
fclose($handle);
}
$array = explode(',',$result);
$a_convert=$array[1];
$a_date=$array[2];
$a_time=$array[3];
$a_date=preg_replace('/"/', ' ', $a_date);
$a_time=preg_replace('/"/', ' ', $a_time);
echo "1 USD <img src=us_ico_flag.jpg> = $a_convert PHP <img src=ph_ico_flag.jpg> ";
echo "<br> $a_date / $a_time ";
echo "<br><a href=http://finance.yahoo.com/q?s=USDPHP=X>Powered by: Yahoo! Finance</a>";
?>
$from = 'USD'; //US Dollar
$to = 'SAR'; //to Philippine Peso
$url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s='. $from . $to .'=X';
$handle = @fopen($url, 'r');
if ($handle) {
$result = fgets($handle, 4096);
fclose($handle);
}
$array = explode(',',$result);
$a_convert=$array[1];
$a_date=$array[2];
$a_time=$array[3];
$a_date=preg_replace('/"/', ' ', $a_date);
$a_time=preg_replace('/"/', ' ', $a_time);
echo "1 USD <img src=us_ico_flag.jpg> = $a_convert PHP <img src=ph_ico_flag.jpg> ";
echo "<br> $a_date / $a_time ";
echo "<br><a href=http://finance.yahoo.com/q?s=USDPHP=X>Powered by: Yahoo! Finance</a>";
?>
= 45.655 PHP