foreach with an array of stdclass objects
- by Jared Steffen
So, what I want to do is quite simple in my mind. I have an array that consists solely of four objects. I want to create a loop that will echo an attribute of each object in the array. The only success I've had, however, is echoing every object and every property of the objects. I've never dealt with objects so this is probably the TRUE root of the problem.
There's been a few revisions but the only thing I've really excelled at is creating error codes.
Here is what I have:
$categories = get_categories(array('child_of' => '8'));
foreach ($categories as $cat) {
echo $cat->name;
};