I'm trying to decode a json response that looks like this and get only the value for USD
{"data":{"currency":"TRX","rates":{"AED":"0.22938983227","USD":"0.06245299"}}}
$url = "https://api.coinbase.com/v2/exchange-rates?currency=TRX";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only!
$result = curl_exec($ch);
$json = json_decode($result, true);
echo $json['USD'];
But I keep getting this error message - Notice: Undefined index: USD in C:\xampp\htdocs*****.php on line 19
var_dump($json)and make sure it is indexed as expected. Note thedatakey.$json['data']['rates']['USD']