tags:

views:

24

answers:

3

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".

A: 

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.

prodigitalson
if they had any ;)
Gordon
@gordon: in that case id avoid that library like the plague :-)
prodigitalson
A: 

Try with

get_class($object[0])

But i've not understood if you want the class name or other.

Nicolò Martini
+2  A: 

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;
Peter Bailey