How to get specific information inside a Json with PHP? [duplicate]

-1

I have this code that returns a JSON

$json_file = file_get_contents("https://api.blinktrade.com/api/v1/BRL/ticker?          crypto_currency=BTC");   
$json_str = json_decode($json_file, true);
var_dump($json_str);

Now, I want to get a specific information inside that JSON, for example, the value of buy, how to proceed?

Thank you.

    
asked by anonymous 26.03.2017 / 17:33

1 answer

1

In this case, you can use the variable that receives the JSON, followed by the key you want to display. In your case:

  $json_str['buy'];

If there was another buy inside the "buy" key, just call it the same way

$json_str['buy']['outra_chave'];
    
26.03.2017 / 21:27