简体   繁体   中英

JSON Url to PHP parsing

I have this JSON url https://api.coinpaprika.com/v1/tickers/eth-ethereum?quotes=INR and I want to display name, symbol and rank as the output. I have used this code in my php file but could not figure out how to display just name, symbol and rank.

<?php

$url = "https://api.coinpaprika.com/v1/tickers/eth-ethereum?quotes=INR";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

?>

With something like this:

echo 'Name: ' . $resp['name'] . '<br>';
echo 'Symbol: ' . $resp['symbol'] . '<br>';
echo 'Rank: ' . $resp['rank'];

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