2017-03-21 72 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); 

?>