zoukankan      html  css  js  c++  java
  • php获取实时汇率

    function getExchangeRate($from_Currency,$to_Currency,$amount){
    $from_Currency = urlencode($from_Currency);
    $to_Currency = urlencode($to_Currency);
    $url = "download.finance.yahoo.com/d/quotes.html?s=".$from_Currency.$to_Currency."=X&f=sl1d1t1ba&e=.html";
    $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);
    $pay_amount=round($data[1]*$amount,2);
    return $pay_amount;
    }
    echo getExchangeRate("CNY","USD","3499");

  • 相关阅读:
    高级打字机
    不等数列
    间谍网络
    医院设置
    题目编号生成器
    传纸条
    聪明的打字员
    倒水问题
    八数码难题
    生日蛋糕
  • 原文地址:https://www.cnblogs.com/chenkg/p/3375524.html
Copyright © 2011-2022 走看看