简体   繁体   中英

PHP: JSON decoding issue

i am trying to get this code to return all the coin names in list format however the following code is not producing a response. is there anything i can change for this to return all the CoinNames from the array in the url

   <?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 );
            }

    ?>

Here you go my dude

    $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>";
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM