Monday, 4 June 2012

Finding Current Exchange rates in php

Here is the code for finding current exchange rates in php... simply copy the code. it will give you details of exchange rates at particular time.........
<?php

$names = array ( 0=> "USD",1=> "JPY",2=> "DKK",3=> "GBP",4=> "SEK",5=> "CHF",6=> "ISK",7=> "NOK",8=> "BGN",9=> "CYP",10=> "CZK",11=> "EEK",12=> "HUF",13=> "LTL",14=> " LVL",15=> "MTL",16=> "PLN",17=> "ROL",18=> "SIT",19=> "SKK",20=> "TRL",21=> "TRY",22=> "AUD",23=> "CAD",24 => "HKD",25 => "NZD",26 => "SGD27 =28=> "EUR ",
29=> "ZAR");
$g = array ( 0=> "USD",1=> "JPY",2="DKK",3=>"GBP",4=>"SEK",5=>"CHF",
6=> "ISK",7=> "NOK",8=> "BGN",9=> "CYP",10=> "CZK",11=> "EEK",12=> "HUF",13=> "LTL",14=> " LVL",15=> "MTL",16=> "PLN",17=> "ROL",18=> "SIT",19=> "SKK",20=> "TRL",21=> "TRY",22=> "AUD",23=> "CAD",24 => "HKD",25 => "NZD",26 => "SGD",27 => "KRW",28=> "EUR ",29=> "ZAR");

for($j=0;$j<count($g);$j++){

for($i=0;$i<count($names);$i++){
$from = $g[$j];
$to = $names[$i];
$url = 'http://finance.yahoo.com/d/quotes.csv?f=l1d1t1&s='.$from.$to.'=X';
$handle = fopen($url, 'r');

if ($handle) {
$result = fgetcsv($handle);
fclose($handle);
}

echo '1 '.$from.' is worth '.$result[0].' '.$to.' Based on data on '.$result[1].' '.$result[2];
echo '</br>';
}

}
?>

1 comment: