Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php将美元转换为其他货币_Php_Codeigniter - Fatal编程技术网

如何使用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

我需要php代码转换美元为所有当地货币。我找到了大量的链接
股票溢出,但它们不起作用。特别是这个$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