note 75582 deleted from ref.xml by tularis
| From: | tularis@php.net | Date: | Fri, 08 Jun 2007 13:22:45 +0000 |
| Subject: | note 75582 deleted from ref.xml by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127324@lists.php.net to get a copy of this message | ||
Note Submitter: ricardo at sismeiro dot com
----
function convert_xml2array(&$result,$root,$rootname='root'){
$n=count($root->children());
if ($n>0){
foreach ($root->children() as $child){
$name=$child->getName();
convert_xml2array($result[$rootname][],$child,$name);
}
} else {
$result[$rootname]= (array) $root;
if (!isset($result[$rootname]['@attributes'])){
$result[$rootname]['@attributes']=array();
}
}
}
function get_array_fromXML($xml){
$result=array();
$doc=simplexml_load_string($xml);
convert_xml2array($result,$doc);
return $result['root'];
}