title: How do I get first item from CakePHP 3 results object
body: <p><strong>TLDR:</strong>  How do I use the first item in a results object?</p>
  
  <hr>
  
  <p>After getting data from the database, I want to pull the first one out and use it separately before repeating through the remaining videos. (All in my template/view file).  If it were an array, I could use something like <code>array_shift</code>, but so far with the object, I'm coming up empty.</p>
  
  <p>First, I get the data in my Controller, and pass it to the View:</p>
  
  <pre><code>$videos = $this-&gt;Videos-&gt;find();
  $this-&gt;set(compact('videos'));
  </code></pre>
  
  <p>Then, in the View (template file), <strong>I've tried this:</strong></p>
  
  <pre><code>$featuredVideo = $videos{0};
  </code></pre>
  
  <blockquote>
    <p>Error Cannot use object of type Cake\ORM\Query as array</p>
  </blockquote>
  
  <p><strong>And this:</strong></p>
  
  <pre><code>$featuredVideo = $videos-&gt;0;
  </code></pre>
  
  <blockquote>
    <p>Error: syntax error, unexpected '0' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' </p>
  </blockquote>
  
  <p><strong>And this:</strong></p>
  
  <pre><code>$featuredVideo = $videos-&gt;toArray()[0];
  </code></pre>
  
  <p>This works (kind of), but then I have to use <code>$featuredVideo</code> as an Array, which is different to everywhere else, and seems non-elegant.</p>
  
  <p><strong>And this:</strong></p>
  
  <pre><code>$featuredVideo = $videos-&gt;first();
  </code></pre>
  
  <p>This is awesome, but it limits the entire object to only the first, so I no longer have the rest of the videos.</p>
  
  <p><strong>And this:</strong></p>
  
  <pre><code>$allVideos = $videos;
  $featuredVideo = $videos-&gt;first();
  </code></pre>
  
  <p>But, apparently since it's an object, the <code>$allVideos</code> is just a reference to the <code>$videos</code>, because they both get reduced to the first video.</p>
  
  <p>I realize this seems like a simple question, and it's likely a simple answer, but I have looked around, and tried the suggestions on how to get the first item from an object with the above results.</p>