【问题标题】:how convert the usd to other currency using php [duplicate]如何使用php将美元转换为其他货币[重复]
【发布时间】:2018-10-09 06:27:31
【问题描述】:

我需要 php 编码来将美元转换为所有本地货币。我找到了很多链接 库存溢出,但他们不工作。特别是这个(https://www.google.com/finance/converter?a=$amount&from=$from&to=$to)链接不工作请解决我的问题

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    使用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;
    }
    

    更多详情Currency Converter

    【讨论】:

    • 这不起作用@billal ahmed
    猜你喜欢
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-16
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    相关资源
    最近更新 更多