PHP access array within simpleXML -
i have soap request returning array of ids. reason, having trouble accessing array within simplexml element.
i did vardump of simplexml object:
die(var_dump($polist)); object(simplexmlelement)#7 (1) { ["int"]=> array(10) { [0]=> string(5) "20622" [1]=> string(5) "20868" [2]=> string(5) "20880" [3]=> string(5) "20883" [4]=> string(5) "21034" [5]=> string(5) "21065" [6]=> string(5) "21136" [7]=> string(5) "21160" [8]=> string(5) "21202" [9]=> string(5) "21247" } }
and var dump of though array:
die(var_dump($polist->int)); object(simplexmlelement)#8 (1) { [0]=> string(5) "20622" }
how access array?
simplexmlelement
implements traversable
, should able do:
foreach( $polist->int $el) echo $el;
or possibly query array xpath:
$array = $polist->xpath( '/int')[0]; foreach( $array $el) echo $el;
Comments
Post a Comment