我正在尝试获取此代码以列表格式返回所有硬币名称,但是以下代码未产生响应。我有什么可以改变的,以便从网址数组中返回所有CoinNames
<?php
$url = "https://min-api.cryptocompare.com/data/all/coinlist";
$data = json_decode(file_get_contents($url), true);
foreach($data as $item){
$coinNames = array_column( $item['Data'], 'CoinName' );
echo implode( ", ", $coinNames );
}
?>
答案 0 :(得分:1)
你在这里走我的兄弟
$url = file_get_contents("https://min-api.cryptocompare.com/data/all/coinlist");
$data = json_decode($url,true);
foreach ($data['Data'] as $coinNames) {
echo $coinNames['CoinName'] . "<br>";
}