note 53461 added to ref.xml
| From: | vladson at pc-labs dot info | Date: | Thu, 02 Jun 2005 09:35:16 +0000 |
| Subject: | note 53461 added to ref.xml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89771@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/ref.xml.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53461
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53461&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53461&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53461&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53461&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53461&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53461&report=yes
Search -- http://master.php.net/manage/user-notes.php