PHP Template - Using extract() and access vars by object. Array is given <p>I want something like this in my template file:</p> <pre><code>&lt;ul&gt; &lt;?foreach($friends as $var):?&gt; &lt;li&gt; &lt;?=$var-&gt;name?&gt; &lt;/li&gt; &lt;?endforeach ?&gt; &lt;/ul&gt; </code></pre> <p>I use this in my model.php:</p> <pre><code>$data = array('friends' =&gt; array( array('name' =&gt; 'testname'), array('name' =&gt; 'testname2') )); // missing code here ? extract($data, EXTR_SKIP); include('template_file.html'); </code></pre> <p>How can I use $var->name to access 'name' as an object in my template file?</p> <p>$data = array() is set.</p> <p>Update:</p> <p>Its because, I dont want to use <code>&lt;?=$var['name']?&gt;</code> in my template.</p>