【发布时间】:2021-05-25 03:14:51
【问题描述】:
一段时间以来,我一直很难从 Json url 中检索 eth 值,它不断返回错误“未定义的偏移量:0”,这对任何给出答案的人来说都很简单,请考虑我是学习者和即将到来的。下面是我的代码
$ethjs = "https://api.coingecko.com/api/v3/simple/token_price/ethereum?contract_addresses=0xdac17f958d2ee523a2206206994597c13d831ec7&vs_currencies=eth";
$ejson = file_get_contents($ethjs);
$ejson = json_decode($ejson, true);
$one_eth = $ejson[0]->eth;
【问题讨论】: