0

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

3 Answers 3

2

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;
Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

@gordon: in that case id avoid that library like the plague :-)
0

Try with

get_class($object[0])

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.