I have a xml parser that returns an associative array. Here’s the structure:
<addresses id="123">
<anonymous-address> <test>data 1 </test>
</anonymous-address>
</addresses>
print_r($this->params) will return
Array
(
[addresses] => Array
(
[id] => 123
[anonymous-address] => Array
(
[0] => Array
(
[test] => Array
(
[VALUE] => data 1
)))))
This array then gets passed through list() as:
list($root, $data) = $parsedXML;
Then I attempt to get an id attribute from root and read to do it this way:
$id = $data[$root]['id'];
Edit: This works for all but one $root value which it 400’s for. This case of the switch ($root) has the same code as the others, so I have no idea why it errs only there.
var_dump($root, $data) outputs
string (9) "addresses"
array(1) {
["addresses"]=>
array(2) {
["id"]=>
string(3) "123"
["anonymous-address"]=>
array(1) {
["VALUE"]=>
string(7) "data 1 "
}
}
}
now $a will be:
so you can get them like this:
so probably