convert stdClass object with XML data to array in PHP
213
Given this object:
stdClass Object (
[customerdata] => <TPSession userid="22" CustomerId="123456"LoginId="123456"/><TPSession userid="26" CustomerId="1234567"LoginId="1234567" />
)
How can I convert this XML data to an array using PHP?
Answer
Solution:
Simply cast it to array:
Answer
Solution:
Xml data in the question is not valid.
You need to wrap it into root element , resolve attribute issue, than you can use simple xml parser to generate object that can be converted to array.
Example
Answer
Solution:
If I understand you want to convert the string contained into the object element to an array, in other words, convert an xml string to an array.
This is what you looking for...
http://php.net/manual/en/function.simplexml-load-string.php
Follow the example on this page.