Can an element of an array return by a function be used without prior assignment?
<p>I have a function returning an array:
<code>function foo(){ return array('foo'=>1,'bar'=>2); }</code></p>

<p>Can I access an element of the return array without assigning it to a temporary variable first (e.g. <code>foo()['bar']</code>)?</p>

<p>The following example returning an object works like a charm:</p>

<pre><code>function foo(){ return (object) array('foo'=>1,'bar'=>2); }
echo foo()->bar;</code></pre>
