note 53461 deleted from ref.xml by bjori
| From: | bjori@php.net | Date: | Mon, 09 Oct 2006 11:06:14 +0000 |
| Subject: | note 53461 deleted from ref.xml by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-118264@lists.php.net to get a copy of this message | ||
Note Submitter: vladson at pc-labs dot info
----
A month ago i was looking for function like one i wrote now, i hope some one who looking for it too,
will find it here...
(it's not like xml_parse_into_struct but it converts xml to array too)
function xml2array($text) {
$reg_exp = '/<(.*?)>(.*?)<\/\\1>/s';
preg_match_all($reg_exp, $text, $match);
foreach ($match[1] as $key=>$val) {
if ( preg_match($reg_exp, $match[2][$key]) ) {
$array[$val][] = xml2array($match[2][$key]);
} else {
$array[$val] = $match[2][$key];
}
}
return $array;
}