I am wondering how I can access a stdObect array of stdObjects. I have an array that looks something like this when printing it with print_r():
stdClass Object ([item] => Array(
[0] => stdClass Object([id] => 0 [name] => Peter)
[1] => stdClass Object([id] => 1 [name] => Jack)))
How can I access the name field? If it not was an array, I could get the attributes by calling the field, like:
$client = new SoapClient("http://url.to.my.wsdl", array("trace" => 0));
echo $client->GetPerson()->name;
But when using arrays, this does not work:
$client = new SoapClient("http://url.to.my.wsdl", array("trace" => 0));
$persons = $client->GetPersons();
echo $persons[0]->name;
That just gives me the error:
Fatal error: Cannot use object of type stdClass as array
According to your print_r info ,just try