我正在寻找一种显示5-6种货币汇率的简单表格的方法。只是一个简单的代码,显示1欧元,挪威克朗,丹麦克朗,英镑等1美元...
有没有人有好办法解决这个问题?
[求助]如果有人在将来需要这个,我在这里找到了一个很好的解决方案: http://www.dynamicguru.com/php/currency-conversion-using-php-and-google-calculator-api/#more-285
以下是我如何使用它:
<?php
function currency($from_Currency,$to_Currency,$amount) {
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode('"', $rawdata);
$data = explode('"', $data['3']);
$var = $data['0'];
return round($var,1);
}
?>
<strong>Results:</strong><br />
100NOK to USD = <?php echo currency("NOK","USD",100); ?><br />
100NOK to EUR = <?php echo currency("NOK","EUR",100); ?><br />
100NOK to GBP = <?php echo currency("NOK","GBP",100); ?><br />
100NOK to SEK = <?php echo currency("NOK","SEK",100); ?><br />
100NOK to DKK = <?php echo currency("NOK","DKK",100); ?><br />
答案 0 :(得分:0)
您可以随时使用Google的货币转换器
这是一个起点:
http://www.google.com/ig/calculator?hl=en&q=1USD=?EUR