I want to take rate_float
as a variable from json following :
{
"time": {
"updated": "Aug 17, 2017 14:21:00 UTC",
"updatedISO": "2017-08-17T14:21:00+00:00",
"updateduk": "Aug 17, 2017 at 15:21 BST"
},
"disclaimer": "This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org",
"bpi": {
"USD": {
"code": "USD",
"rate": "4,504.1325",
"description": "United States Dollar",
"rate_float": 4504.1325
},
"IDR": {
"code": "IDR",
"rate": "60,204,487.0613",
"description": "Indonesian Rupiah",
"rate_float": 60204487.0613
}
}
}
I take json from : https://api.coindesk.com/v1/bpi/currentprice/IDR.json
I tried by typing the following coding but for which I got all values from IDR,
I just wanted a rate_float
only
$url_json="http://api.coindesk.com/v1/bpi/currentprice/IDR.json";
$result=file_get_contents($url_json);
$array=json_decode($result, true);
foreach($array['bpi']['IDR'] as $currency => $data) {
echo $data."<br>";
}
Thank you, please help