Reputation: 3754
i have an array after convert it from xml data and i have var_dump the data in array like :
object(SimpleXMLElement)#651 (1) {
["authenticationSuccess"]=>
object(SimpleXMLElement)#652 (1) {
["user"]=>
string(9) "yassine"
}
}
i want to get the value the attribut user that equal "yassine" in this cas . i trying
$xml["authenticationSuccess"]["user"]
but not working , it return null value , is there any solution to get this data from the array .
some help please
Upvotes: 0
Views: 52
Reputation: 7285
As the var_dump
says, you have an object
instead of an associative array. You can access object fields like this:
$xml->authenticationSuccess->user;
or this:
$xml->{"authenticationSuccess"}->{"user"};
Upvotes: 2
Reputation: 1390
It seems your variable is not array but object, so you need to use $xml->authenticationSuccess->user;
Upvotes: 3