开发者

PHP - how to access this data structure?

This is a newbie question - how do I access the value0, value1, ... entities?

         object(SimpleXMLElement)#43 (2) {
            ["@attributes"]=>
            array(3) {
              ["ABC"]=>
              string(1) 开发者_如何学Go"1"
              ["DEF"]=>
              string(14) "recordXYZ"
              ["GHI"]=>
              string(1) "@"
            }
            ["qwerty"]=>
            array(5) {
              [0]=>
              string(4) "value0"
              [1]=>
              string(1) "value1"
              [2]=>
              string(2) "value2"
              [3]=>
              string(2) "value3"
              [4]=>
              string(4) "value4"
            }
          }


Just plain array access

$value0 = $object->qwerty[0]
$value1 = $object->qwerty[1]


When $object is the SimpleXMLElement object you showed, then $object->qwerty is the array with your values.


foreach ($object->querty as $val) {
    var_dump($val);
}


See the children() function in the SimpleXMLElement documentation for an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜