loop through array of objects

php

Solution

No. You will have to use an `if`:

foreach ($pages as $page) {
    if ($page->_visible == 1) {
        echo "<li>page</li>";
    }
}

(Note also you misspelt `visible` in the array, perhaps a typo?)

Problem

I Have an array called $pages content is as follows: ``` Array ( [01-about-us] => Page Object ( [_uri] => about-us [_menuItem] => 01 [_visable] => 1 ) [02-contact] => Page Object ( [_uri] => contact [_menuItem] => 02 [_visable] => 1 ) [_sitemap] => Page Object ( [_uri] => sitemap [_menuItem] => [_visable] => ) [home] => Page Object ( [_uri] => home [_menuItem] => [_visable] => 1 ) ) ``` is there an easy way to loop through and get page objects by there properties ie: ``` <?php foreach($pages->_visible() AS $p): ?> <li> page </li> <?php endforeach ?> ```

Original source