Returning arrays and accessing values
<p>I'm fairly new to PHP and I am trying to return an array from a class function and then access its values like so:</p>

<pre><code>  &lt;?php 
    class Foo
        {
            private $access;

            public function setAccess($access)
            {
                $this-&gt;access = $access;
            }


            public function getAccess()
            {
                return $this-&gt;access;
            }
        }


$var = new Foo();
$var-&gt;setAccess(array(1,2,3,4));

$var2 = $var-&gt;getAccess()[2];

echo $var2;

?&gt;
</code></pre>

<p>When I try to run a page with this code, I get the following:</p>

<pre><code>Parse error: syntax error, unexpected '[' in arraytest.php on line 22
</code></pre>

<p>How can I access the values for my private arrays in my class?</p>
