Q:

print_r in PHP returning "stdClass Object" on screen after using json_decode

<?php
$content = file_get_contents("https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD");
$result = json_decode($content);
print_r ( $result);
?>

So I created that bit of code, but when I go to test it it returns " stdClass Object ( [USD] => 7531.74 )" on the screen. All I want is the 7531.74, how do I strip away the rest of it?

A:

You can do one of two things:
// as a stdClass Object
$temp = json_decode($content);
$result = $temp->USD ;

Or, use an array:
// as an associative Array
$temp = json_decode($content,true);
$result = $temp['USD'] ;

