This is related to my earlier question here: Trying to read XML nodes using PHP DOM
I have an array which has elements that look like this:
[rpc.pingomatic.com] => Array
(
[http://www.example.com] => Array
(
[0] => SimpleXMLElement Object
(
[name] => flerror
[value] => SimpleXMLElement Object
(
[boolean] => 0
)
)
[1] => SimpleXMLElement Object
(
[name] => message
[value] => SimpleXMLElement Object
(
[string] => Pings being forwarded to 11 services!
)
)
)
I want to retrieve the data and finally display it in this manner:
flerror:0
Message from directory:Pings being forwarded to 11 services
I can use this to retrieve the necessary fields:
echo $response->name;
echo $response->value->boolean;
echo $response->value->string;
However, I am using a foreach loop to traverse through the array, and not all elements have the fields named boolean and string. They might have something like flag instead of boolean, etc.
Is there a generic way to retrieve the necessary data using the same foreach loop?