Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.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_Api_Codeigniter_Google Finance - Fatal编程技术网

Php 谷歌金融货币转换器不工作

Php 谷歌金融货币转换器不工作,php,api,codeigniter,google-finance,Php,Api,Codeigniter,Google Finance,我使用google finance为currecy converter编写的代码不起作用 $amount="10"; $from="USD"; $to="INR"; $data = file_get_contents("https://finance.google.com/bctzjpnsun/converter?a=$amount&from=$from&to=$to"); preg_match("/<span class=bld&g

我使用google finance为currecy converter编写的代码不起作用

$amount="10";
      $from="USD";
      $to="INR";
    $data = file_get_contents("https://finance.google.com/bctzjpnsun/converter?a=$amount&from=$from&to=$to");
    preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
    $converted = preg_replace("/[^0-9.]/", "", $converted[1]);
    echo number_format(round($converted, 3),2); exit;
$amount=“10”;
$from=“USD”;
$to=“印度卢比”;
$data=文件\u获取\u内容(“https://finance.google.com/bctzjpnsun/converter?a=$amount&from=$from&to=$to”);
预匹配(“/(.*)/”,$data,$converted);
$converted=preg_replace(“/[^0-9.]/”,“,$converted[1]);
回波号_格式(圆形($converted,3),2);出口;
我得到的结果是0.00

除此之外还有其他方法吗

$amount="10";
$from="USD";
$to="INR";
$url = file_get_contents('https://free.currencyconverterapi.com/api/v5/convert?q=' . $from . '_' . $to . '&compact=ultra');
$json = json_decode($url, true);
$rate = implode(" ",$json);
$total = $rate * $amount;
$rounded = round($total); 
return $rounded;
使用此代码


使用此代码

谷歌的URL不再工作

谷歌的URL不再工作