2017-03-21 33 views

回答

3

你的代码中使用的file_get_contents两次,看看会是:

<?php 
$tick = file_get_contents('https://api.coinmarketcap.com/v1/ticker/ethereum/'); 
$url = $tick; 
echo $url; 
//$json = file_get_contents($url); 
$data = json_decode($tick, TRUE); 

$usd = $data[0]["price_usd"]; 
echo $usd; 
?> 
0

试试这个

<?php 
$json = file_get_contents('https://api.coinmarketcap.com/v1/ticker/ethereum/'); 
$data = json_decode($json); 
var_dump($data[0]->price_usd); 

?>