How to get specific information inside a Json with PHP?

Asked

Viewed 433 times

0

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 specific information within that JSON, for example, the buy value, how to proceed?

Grateful.

1 answer

2


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

  $json_str['buy'];

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

$json_str['buy']['outra_chave'];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.