I have an xml data and i need to convert this xml into an array ,i use the bellow PHP code,
$xml = new SimpleXMLElement($data); // $data contain the xml data
$transaction_result = json_decode(json_encode($xml),true);
This is working ,but the problem is.
If a node in xml is empty,That value automatically converted as an empty array.Is it possible to remove the empty array?
Example:
if the node in xml is <name></name> then the result become
array('name'=>array());
My expected result is
array('name'=>'');
How is it possible to overcome this issue?
LIBXML_NOBLANKSsee: php.net/manual/en/libxml.constants.php