hello i’m trying to save the values of a SimpleXMLElement to a $_SESSION but the values are entered as “SimpleXMLElement Object”. code below:
$xml = new SimpleXMLElement($auth_info);
$_SESSION[userName] = $xml->profile->preferredUsername; (garfx)
$_SESSION[email] = $xml->profile->verifiedEmail;
$_SESSION[givenName] = $xml->profile->name->givenName;
$_SESSION[lastName] = $xml->profile->name->familyName;
results example
Array
(
[userName] => SimpleXMLElement Object
()
)
i would like
Array
(
[userName] => garfx
)
SimpleXML elements can be used as strings, but you need to “cast” them to a string.
Casting in PHP is done by prefixing the data type to a value,
so for example,
Would make
$barbe a string containing the character “1”.The solution for the above would be:-