5〜6の為替レートで簡単な表を表示する方法を探しています。EUR、NOK、DKK、GBPなどで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 />