I am trying to grab the "price" of Bitcoin using the script below. Essentially it visits the coinmarketcap api and prints out the price of bitcoin. However, I am unsure as to what this error means or how I can fix it
My code
<?php
$url = "https://api.coinmarketcap.com/v2/ticker/";
$contents = file_get_contents($url);
$decode_content = json_decode($contents);
$myprice = $decode_content->data->1->name;
echo "Price: " . $myprice;
?>
Error msg
Fatal error: Cannot use object of type stdClass as array