title: PHP - How to get object from array when array is returned by a function?
body: <p>how can I get a object from an array when this array is returned by a function?</p>
  
  <pre><code>class Item {
      private $contents = array('id' =&gt; 1);
  
      public function getContents() {
          return $contents;
      }
  }
  
  $i = new Item();
  $id = $i-&gt;getContents()['id']; // This is not valid?
  
  //I know this is possible, but I was looking for a 1 line method..
  $contents = $i-&gt;getContents();
  $id = $contents['id'];
  </code></pre>