根据ID值PHP

时间:2018-01-27 13:18:19

标签: php json

我从两个API链接获取json数据。

第一个For-Loop包含市场ID(由所有ID组成但第二个循环没有所有ID)和BaseCurrencyCode

First Loop Output :
MarketID -> BaseCurrency Code
18 -> LTC/BTC 
19 -> UNO/BTC 
20 -> SYS/BTC 
21 -> DOGE/BTC 
22 -> KOBO/BTC 
23 -> BITZ/BTC 
24 -> DGC/BTC 
25 -> MEC/BTC 

第二次循环输出:

MarketID -> CurrencyValue
18 -> 0.01588636 
19 -> 0.01120000 
21 -> 0.00000065 
22 -> 0.00000711 
24 -> 0.00000877 
25 -> 0.00000761 
26 -> 0.00000007 
31 -> 0.00002200 
34 -> 0.00000445 

我需要结合两个循环 和输出寻找

MarketID  BaseCurrency   Value 
18   ->   LTC/BTC      0.01588636

重要: - 如果BTC是Bas​​ecurrency,则打印所有BaseCurrency BTC对 类似地,LTC碱基对ETH对DOGE对

PHP脚本

<?php
include 'pappu.php';
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");




$grabs=ngegrab('https://www.coinexchange.io/api/v1/getmarkets');
$jsons = json_decode($grabs);

if($jsons)
foreach ($jsons->result as $sam)
{
  $market= $sam->MarketID;
  $marketcode=$sam->MarketAssetCode;
  $basecurrency=$sam->BaseCurrencyCode;

echo " $market -> $marketcode/$basecurrency <br/>";

}

$grabs=ngegrab('https://www.coinexchange.io/api/v1/getmarketsummaries');
$jsons = json_decode($grabs);

if($jsons)
foreach ($jsons->result as $sam)
{
  $market= $sam->MarketID;
  $price= $sam->LastPrice;
echo " $market -> $price <br/>";

}

0 个答案:

没有答案