Help with Json to get API value

1

I'm trying to get only the return of a variable from this api "buy" that would be the purchase value, but when I try it returns me the whole table, could anyone enlighten me?

$data = json_decode(file_get_contents("https://broker.negociecoins.com.br/api/v3/btcbrl/ticker"));
echo "<pre>";
print_r($data);
echo "</pre>";
    
asked by anonymous 07.08.2018 / 22:03

2 answers

1

Try using as follows:

$data = json_decode(file_get_contents("https://broker.negociecoins.com.br/api/v3/btcbrl/ticker"), true);

This will turn JSON into an associative array, so you should get the answer you need.

    
07.08.2018 / 22:23
0

Use print_r($data->buy);

    
08.08.2018 / 13:25