How to get specific entry from JSON file in PHP
<p>I have <a href="https://api.coinmarketcap.com/v1/ticker/" rel="nofollow noreferrer">this site's</a> output which gives me the value of 750+ altcoins.</p>
<p>I get the output, and decode it as <code>$data</code>.</p>
<p>Let's simplify it to:</p>
<pre><code>[
    {
        &quot;id&quot;: &quot;bitcoin&quot;, 
        &quot;name&quot;: &quot;Bitcoin&quot;, 
        &quot;symbol&quot;: &quot;BTC&quot;, 
        &quot;rank&quot;: &quot;1&quot;, 
        &quot;price_usd&quot;: &quot;610.561&quot;, 
        &quot;price_btc&quot;: &quot;1.0&quot;, 
        &quot;24h_volume_usd&quot;: &quot;44104400.0&quot;, 
        &quot;market_cap_usd&quot;: &quot;9688885050.0&quot;, 
        &quot;available_supply&quot;: &quot;15868824.0&quot;, 
        &quot;total_supply&quot;: &quot;15868824.0&quot;, 
        &quot;percent_change_1h&quot;: &quot;0.12&quot;, 
        &quot;percent_change_24h&quot;: &quot;0.25&quot;, 
        &quot;percent_change_7d&quot;: &quot;-1.61&quot;, 
        &quot;last_updated&quot;: &quot;1473929966&quot;
    }, 
    {
        &quot;id&quot;: &quot;ethereum&quot;, 
        &quot;name&quot;: &quot;Ethereum&quot;, 
        &quot;symbol&quot;: &quot;ETH&quot;, 
        &quot;rank&quot;: &quot;2&quot;, 
        &quot;price_usd&quot;: &quot;12.0793&quot;, 
        &quot;price_btc&quot;: &quot;0.0197864&quot;, 
        &quot;24h_volume_usd&quot;: &quot;8171040.0&quot;, 
        &quot;market_cap_usd&quot;: &quot;1014555388.0&quot;, 
        &quot;available_supply&quot;: &quot;83991240.0&quot;, 
        &quot;total_supply&quot;: &quot;83991240.0&quot;, 
        &quot;percent_change_1h&quot;: &quot;0.21&quot;, 
        &quot;percent_change_24h&quot;: &quot;1.25&quot;, 
        &quot;percent_change_7d&quot;: &quot;4.92&quot;, 
        &quot;last_updated&quot;: &quot;1473929962&quot;
    }, 
    {
        &quot;id&quot;: &quot;ripple&quot;, 
        &quot;name&quot;: &quot;Ripple&quot;, 
        &quot;symbol&quot;: &quot;XRP&quot;, 
        &quot;rank&quot;: &quot;3&quot;, 
        &quot;price_usd&quot;: &quot;0.00597615&quot;, 
        &quot;price_btc&quot;: &quot;0.00000979&quot;, 
        &quot;24h_volume_usd&quot;: &quot;1017240.0&quot;, 
        &quot;market_cap_usd&quot;: &quot;211062429.0&quot;, 
        &quot;available_supply&quot;: &quot;35317458440.0&quot;, 
        &quot;total_supply&quot;: &quot;99997205581.0&quot;, 
        &quot;percent_change_1h&quot;: &quot;-0.16&quot;, 
        &quot;percent_change_24h&quot;: &quot;1.53&quot;, 
        &quot;percent_change_7d&quot;: &quot;0.88&quot;, 
        &quot;last_updated&quot;: &quot;1473929942&quot;
    }, 
    {
        &quot;id&quot;: &quot;litecoin&quot;, 
        &quot;name&quot;: &quot;Litecoin&quot;, 
        &quot;symbol&quot;: &quot;LTC&quot;, 
        &quot;rank&quot;: &quot;4&quot;, 
        &quot;price_usd&quot;: &quot;3.83018&quot;, 
        &quot;price_btc&quot;: &quot;0.00627398&quot;, 
        &quot;24h_volume_usd&quot;: &quot;1101600.0&quot;, 
        &quot;market_cap_usd&quot;: &quot;182184060.0&quot;, 
        &quot;available_supply&quot;: &quot;47565404.0&quot;, 
        &quot;total_supply&quot;: &quot;47565404.0&quot;, 
        &quot;percent_change_1h&quot;: &quot;-0.11&quot;, 
        &quot;percent_change_24h&quot;: &quot;0.14&quot;, 
        &quot;percent_change_7d&quot;: &quot;-3.61&quot;, 
        &quot;last_updated&quot;: &quot;1473929943&quot;
    }, 
    {
        &quot;id&quot;: &quot;monero&quot;, 
        &quot;name&quot;: &quot;Monero&quot;, 
        &quot;symbol&quot;: &quot;XMR&quot;, 
        &quot;rank&quot;: &quot;5&quot;, 
        &quot;price_usd&quot;: &quot;10.4646&quot;, 
        &quot;price_btc&quot;: &quot;0.0171415&quot;, 
        &quot;24h_volume_usd&quot;: &quot;4920040.0&quot;, 
        &quot;market_cap_usd&quot;: &quot;134987751.0&quot;, 
        &quot;available_supply&quot;: &quot;12899466.0&quot;, 
        &quot;total_supply&quot;: &quot;12899466.0&quot;, 
        &quot;percent_change_1h&quot;: &quot;-0.35&quot;, 
        &quot;percent_change_24h&quot;: &quot;-2.47&quot;, 
        &quot;percent_change_7d&quot;: &quot;-14.04&quot;, 
        &quot;last_updated&quot;: &quot;1473929949&quot;
    }, 
]
</code></pre>
<p>How do I get the <code>price_usd</code> of let's say, ripple? I know that I can do <code>$data[3]['price_usd']</code>, however the info is based on the rank. The rank changes. How do I get it to retrieve the value of ripple without using <code>[1]</code>? I've tried <code>$data['bitcoin']['price_usd']</code>, but to no avail.</p>
<p>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.</p>
<p>Regards</p>