如何使用php将美元转换为其他货币
我需要php代码转换美元为所有当地货币。我找到了大量的链接如何使用php将美元转换为其他货币,php,codeigniter,Php,Codeigniter,我需要php代码转换美元为所有当地货币。我找到了大量的链接 股票溢出,但它们不起作用。特别是这个$amount&from=$from&to=$to链接不起作用,请给出我问题的解决方案。使用google API在php中转换货币是一个简单的方法 function currencyConverter($from_currency, $to_currency, $amount) { $from_Currency = urlencode($from_currency); $to_Currency
股票溢出,但它们不起作用。特别是这个$amount&from=$from&to=$to链接不起作用,请给出我问题的解决方案。使用google API在php中转换货币是一个简单的方法
function currencyConverter($from_currency, $to_currency, $amount) {
$from_Currency = urlencode($from_currency);
$to_Currency = urlencode($to_currency);
$encode_amount = urlencode($amount);
$get = file_get_contents("https://www.google.com/finance/converter?a=$encode_amount&from=$from_Currency&to=$to_Currency");
$get = explode("<span class=bld>",$get);
$get = explode("</span>",$get[1]);
$converted_currency = preg_replace("/[^0-9\.]/", null, $get[0]);
return $converted_currency;
}
有关的更多详细信息,请参见@billal ahmed