开源中国 2018 年度最后一场技术盛会邀你来约~错过就要等明年啦!点此立即预约

pycorvn / RMB汇率转换接口PHP

Watch 1 Star 0 Fork 0
Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
通过抓取和讯网RMB比价中心数据,解析出需要的银行及币种汇率 spread retract

Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

RMB汇率转换接口

Description

通过抓取和讯网RMB比价中心数据,解析出需要的银行及币种汇率

Software Architecture

<?php

    $data = file_get_contents('http://data.bank.hexun.com/other/cms/foreignexchangejson.ashx');
    $data = iconv('gbk', 'utf-8', $data);
    $data = preg_replace('/},{/', '|', substr($data, 22, -3));
    $data = explode('|', $data);
    $list = [];
    foreach($data as $v) {
        $v = explode(',', $v);
        $item = [];
        foreach($v as $o) {
            $p = strpos($o, ':');
            $item[substr($o, 0, $p)] = trim(substr($o, $p+1), '\'');
        }
        array_push($list, $item);
    }
    header('Content-Type:text/html;charset=utf-8');
    echo '<pre>';
    print_r($list);
    
    /**
    Array
    (
        [0] => Array
            (
                [bank] => 工商银行
                [currency] => 阿联酋 迪拉姆
                [code] =>
                [currencyUnit] =>
                [cenPrice] =>
                [buyPrice1] => 171.8200
                [sellPrice1] => 173.0900
                [buyPrice2] => 166.4400
                [sellPrice2] => 173.0900
                [releasedate] => 2018-4-27 23:37:35
            )

        [1] => Array
            (
                [bank] => 工商银行
                [currency] => 澳大利亚元
                [code] => AUD
                [currencyUnit] =>
                [cenPrice] =>
                [buyPrice1] => 478.1600
                [sellPrice1] => 481.7100
                [buyPrice2] => 464.4900
                [sellPrice2] => 481.7100
                [releasedate] => 2018-4-30 9:05:54
            )
        ...
    **/

Contribution

  1. Fork the project
  2. Create Feat_xxx branch
  3. Commit your code
  4. Create Pull Request

Gitee Feature

  1. You can use Readme_XXX.md to support different languages, such as Readme_en.md, Readme_zh.md
  2. Gitee blog blog.gitee.com
  3. Explore open source project https://gitee.com/explore
  4. The most valuable open source project GVP
  5. The manual of Gitee http://git.mydoc.io/
  6. The most popular members https://gitee.com/gitee-stars/

Comments ( 0 )

You need to Sign in for post a comment

Help Search