Reputation: 93156
ive got an object that looks like this with print_r():
SimpleDOM Object ( [0] => continent )
i wonder how i could get the continent as a string?
i have tried gettype($object[0]);
it still says its an object.
i just want to get the string "continent".
Upvotes: 0
Views: 68
Reputation: 105878
Is this SimpleDOM the one you're using?
If so, it looks like that value would be stored in the _Element::$tagName
variable. So maybe try this?
echo $object[0]->tagName;
Upvotes: 2
Reputation: 5220
Try with
get_class($object[0])
But i've not understood if you want the class name or other.
Upvotes: 0
Reputation: 60413
Im not familar with SimpleDOM but it would seem to me that its something similar in implementation to SimpleXMLElement. If this is the case then casting the object to a string should get you what you want:
$continent = (string) $object;
or from its parent node you can probably access it like so:
$continent = $parent->continent;
These are only guesses though. I would taka look at the SimpleDOM documentation.
Upvotes: 0