Hi every body
Can you help me with this problem
I'm using the script bellow to extract an array from the xml file. I get this array:
Array
(
[0] => Array
(
[name] => MESSAGE_DELIVERY
[child] => Array
(
[0] => Array
(
[name] => AUTHENTICATION
[child] => Array
(
[0] => Array
(
[name] => USER_NAME
[content] => Array
(
[0] => client
)
)
[1] => Array
(
[name] => PASSWORD
[content] => Array
(
[0] => secret
)
)
)
)
[1] => Array
(
[name] => MOBILE_ORIGINATED
[attrs] => Array
(
[ID] => b8e059:fd94881a39:-797
[REDELIVERED] => false
[TEST] => false
)
[child] => Array
(
[0] => Array
(
[name] => MO_MESSAGE
[attrs] => Array
(
[ID] => 12345678
)
[child] => Array
(
[0] => Array
(
[name] => TEXT
[content] => Array
(
[0] => motn pr26100000 I would like to know if somebody else is interested by
)
)
[1] => Array
(
[name] => KEYWORD
[content] => Array
(
[0] => motn
)
)
[2] => Array
(
[name] => STOP
[content] => Array
(
[0] => false
)
)
[3] => Array
(
[name] => MOBILE_NUMBER
[content] => Array
(
[0] => 441234567890
)
)
[4] => Array
(
[name] => NETWORK_NAME
[content] => Array
(
[0] => o2
)
)
[5] => Array
(
[name] => INBOUND_NUMBER
[content] => Array
(
[0] => 12345
)
)
)
)
)
)
)
)
)
I want to reduce this big array on a simple array like this:
Array(
[USER_NAME]=>client
[PASSWORD]=>secret
[MO_MESSAGE]=>123456
[TEXT]=>motn pr26100000 I would like to know if somebody else is interested by
[KEYWORD]=>motn
---ect
)
The problem is with the function parse_depth wich I used recursively to get all the information I need. It's not working as I intended
This is a script php I use to parse my xml file
<?php
include("xmlparser.php");
$p =& new xmlParser();
$p->parse('mo_originated.xml');
function parse_depth(&$array){
if (!is_array($array)){
return $array;
}
else{
foreach ($array as $key=>$value)
$array[$key]=parse_depth($value);
}
return $array;
}
$data=parse_depth($p->output);
print_r($data);
?>
Thanks