I have this site's output which gives me the value of 750+ altcoins.
I get the output, and decode it as $data
.
Let's simplify it to:
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "610.561",
"price_btc": "1.0",
"24h_volume_usd": "44104400.0",
"market_cap_usd": "9688885050.0",
"available_supply": "15868824.0",
"total_supply": "15868824.0",
"percent_change_1h": "0.12",
"percent_change_24h": "0.25",
"percent_change_7d": "-1.61",
"last_updated": "1473929966"
},
{
"id": "ethereum",
"name": "Ethereum",
"symbol": "ETH",
"rank": "2",
"price_usd": "12.0793",
"price_btc": "0.0197864",
"24h_volume_usd": "8171040.0",
"market_cap_usd": "1014555388.0",
"available_supply": "83991240.0",
"total_supply": "83991240.0",
"percent_change_1h": "0.21",
"percent_change_24h": "1.25",
"percent_change_7d": "4.92",
"last_updated": "1473929962"
},
{
"id": "ripple",
"name": "Ripple",
"symbol": "XRP",
"rank": "3",
"price_usd": "0.00597615",
"price_btc": "0.00000979",
"24h_volume_usd": "1017240.0",
"market_cap_usd": "211062429.0",
"available_supply": "35317458440.0",
"total_supply": "99997205581.0",
"percent_change_1h": "-0.16",
"percent_change_24h": "1.53",
"percent_change_7d": "0.88",
"last_updated": "1473929942"
},
{
"id": "litecoin",
"name": "Litecoin",
"symbol": "LTC",
"rank": "4",
"price_usd": "3.83018",
"price_btc": "0.00627398",
"24h_volume_usd": "1101600.0",
"market_cap_usd": "182184060.0",
"available_supply": "47565404.0",
"total_supply": "47565404.0",
"percent_change_1h": "-0.11",
"percent_change_24h": "0.14",
"percent_change_7d": "-3.61",
"last_updated": "1473929943"
},
{
"id": "monero",
"name": "Monero",
"symbol": "XMR",
"rank": "5",
"price_usd": "10.4646",
"price_btc": "0.0171415",
"24h_volume_usd": "4920040.0",
"market_cap_usd": "134987751.0",
"available_supply": "12899466.0",
"total_supply": "12899466.0",
"percent_change_1h": "-0.35",
"percent_change_24h": "-2.47",
"percent_change_7d": "-14.04",
"last_updated": "1473929949"
},
]
How do I get the price_usd
of let's say, ripple? I know that I can do $data[3]['price_usd']
, however the info is based on the rank. The rank changes. How do I get it to retrieve the value of ripple without using [1]
? I've tried $data['bitcoin']['price_usd']
, but to no avail.
I've searched stackexchange for answers on this, but people have only told me what I know so far. Not how to find the value of a specific entry.
Regards