Question

I have been trying to figure this out for a while now. Please any advice would be appreciated. I just need to access the array for ["Item"]. How do I gain access to this?

array(1) {
  [0]=>
  object(SimpleXMLElement)#16 (2) {
    ["@attributes"]=>
    array(2) {
      ["Name"]=>
      string(10) "AuthorList"
      ["Type"]=>
      string(4) "List"
    }
    ["Item"]=>
    array(3) {
      [0]=>
      string(9) "Smith, Joe"
      [1]=>
      string(10) "Peter, Ann"
      [2]=>
      string(18) "Magoo, Mr"
    }
  }
}
Was it helpful?

Solution

Assuming this structure is in a variable called var1, you should be able to access Item using:

$var1[0]->Item // returns the array

OTHER TIPS

I try to explain it.

Like you see, your first array index is an object. If you see something like this in your var_dump than you can access it through deferencing the object.

It's the same like you would create an object and would like to access a public variable:

$var1 = new Object();
// when your Object variables are public so you could access them by deference the Object

echo $var1->myVariable; // will echo the public variable "myVariable" 

So the answer from adam is the right one :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top