Q:

How to echo JSON data using PHP

{
  USD_INR: {
    2017-12-31: 63.830002
  },
  INR_USD: {
    2017-12-31: 0.015667
  }
}

I have tried with following method,
$url = file_get_contents("https://free.currencyconverterapi.com/api/v5/convert?q=USD_INR,INR_USD&compact=ultra&date=2017-12-31");
$result = json_decode($url);
echo $result->USD_INR;

but it did't works, can any one help me where I'm doing wrong.

A:

Just pass date in $todaysDate variable which you want price.
$todaysDate = "2017-12-31";
$url = file_get_contents("https://free.currencyconverterapi.com/api/v5/convert?q=USD_INR,INR_USD&compact=ultra&date=$todaysDate");
$result = json_decode($url);

echo ($result->USD_INR->$todaysDate);

