I really am clueless when it comes to object-oriented programmings, so forgive me if this is obvious...
I am using a Zend extension which returns a request as a nested object. I need property a
based on if the object has property b
. Right now I am using a foreach loop with a conditional to search for property b
and, if I get a match, set my variable to property a
.
Something like:
foreach($nested_object as $object) {
if($object -> foo -> bar == "match") {
$info = $object -> stuff -> junk;
}
}
I was hoping there was a more elegant way to do this, along the lines of XPath (but certainly it doesn't have to be remotely close to XPath, just something as simple).
So if I know the property I need, is there a way in PHP to retrieve any and all objects with that property?