title: Better way to get first element of returned array
body: <p>I found myself using this:</p>
  
  <pre><code>$var=(string)array_shift(array_values($item-&gt;xpath($s)));
  </code></pre>
  
  <p>where $s is an xpath search string and the return is an array of objects that contain strings.</p>
  
  <p>It works, but I'm not sure it's the best way to get the data I want.</p>
  
  <p>I could use a tempvar, but I wanted to avoid that.</p>
  
  <p>Any suggestions?</p>