views:

31

answers:

2

After an xPath, I'm left with this var_dump:

array(1) {
  [0]=>
  object(SimpleXMLElement)#2 (1) {
    [0]=>
    string(11) "22-99586795"
  }
}

echoing the damn thing only gives me "Array()"

How do I get the bloody string out?

Thanks

+1  A: 

It's an array with one item, so you need to do:

$myelement[0];

or

$myelement[0][0];

(I can't tell from your question which element you're referring to)

Skilldrick
`var_dump($newXML->xpath("//ID")[0]);` Has been tried to no avail
Codemonkey
`$id = implode("", $newXML->xpath("//ID"));` worked, but is a method so dirty really necessary to fetch data in one line? (My goal is to get ID from XML in **one** line of code)
Codemonkey
You can't use array subscripts on return values in PHP - you have to assign the return value to a variable and subscript that.
Skilldrick
A: 

Try casting it to string

print (string)$yourarray[0];
Anti Veeranna