title: Get first element in PHP stdObject
body: <p>I have an object (stored as $videos) that looks like this</p>
  
  <pre><code>object(stdClass)#19 (3) {
    [0]=&gt;
    object(stdClass)#20 (22) {
      ["id"]=&gt;
      string(1) "123"
  
    etc...
  </code></pre>
  
  <p>I want to get the ID of just that first element, without having to loop over it.</p>
  
  <p>If it were an array, I would do this:</p>
  
  <pre><code>$videos[0]['id']
  </code></pre>
  
  <p>It used to work as this:</p>
  
  <pre><code>$videos[0]-&gt;id
  </code></pre>
  
  <p>But now I get an error "Cannot use object of type stdClass as array..." on the line shown above. Possibly due to a PHP upgrade.</p>
  
  <p>So how do I get to that first ID without looping? Is it possible?</p>
  
  <p>Thanks!</p>