Get Live Currency Rate From Yahoo Finance API

Here is a simple PHP Function to get live currency conversion from Yahoo Finance API

In my example i am gettting the value of 100 Dansih Krone in US Dollar

<?php
function yahoofinance_convert($from, $to) {
$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);
}
$return = explode(',',$result);
$to_value = $return[1] * 100;

return $to_value;
}

echo "Value of 100 DKK is " . yahoofinance_convert("DKK", "USD") . "$";

?>
VN:F [1.9.22_1171]
Rating: 5.5/6 (4 votes cast)
Get Live Currency Rate From Yahoo Finance API, 5.5 out of 6 based on 4 ratings

2 thoughts on “Get Live Currency Rate From Yahoo Finance API”

Leave a Reply

Your email address will not be published. Required fields are marked *