title: Extracting a JSON value from an external API with PHP
body: <p>How can I get <code>videoId</code> (selected on image) in PHP? It's my code and it's not working (I'm talking about <code>echo [...]</code>). It returns: </p>
  
  <blockquote>
    <p>Fatal error: Cannot access empty property in /home/****/public_html/ytshots/index.php on line 38</p>
  </blockquote>
  
  <pre><code>$url = 'https://www.googleapis.com/youtube/v3/search?maxResults=4&amp;type=video&amp;order=date&amp;part=snippet&amp;forUsername=MKL&amp;key=****';
  $data = file_get_contents($url);
  $characters = json_decode($data);
  
  echo $characters-&gt;$items['videoId'];
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/5AWeo.png" alt="image"></p>