Trying to get property of non-object : <p>I'm getting "Trying to get property of non-object" while trying to this code.</p>

<pre><code>&lt;?php foreach($pages as $page=&gt;$p): ?&gt;
&lt;h2 class="section-title text-center wow fadeInDown"&gt;&lt;?php echo $page[0]-&gt;title;  ?&gt;&lt;/h2&gt;
&lt;p class="text-center wow fadeInDown"&gt;&lt;?php echo strip_tags(html_entity_decode($page[0]-&gt;description)); ?&gt;&lt;/p&gt;
&lt;?php endforeach; ?&gt;
</code></pre>
