note 25782 deleted from function.xml-parse-into-struct by cmb
| From: | cmb@php.net | Date: | Sun, 06 Oct 2019 08:26:43 +0000 |
| Subject: | note 25782 deleted from function.xml-parse-into-struct by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212523@lists.php.net to get a copy of this message | ||
Note Submitter: ambi at gmx dot de
----
Sorry.. unreachable and unneeded code in my posting above :-)
Here is the fixed version:
function xml_condense_tree($tree) {
if ($tree["children"]) {
unset($nodecounters);
foreach ($tree['children'] as $index => $node) {
if (!isset($nodecounters[$node['tag']]))
$nodecounters[$node['tag']]=1;
else $nodecounters[$node['tag']]++;
}
foreach ($tree['children'] as $index => $node) {
if (isset($node['children'])) {
$tree['children'][$index] = xml_condense_tree($node);
} elseif (isset($node['value']) and !$node['attributes'] and
$nodecounters[$node['tag']]==1) {
$tree['values'][$node['tag']] = $node['value'];
unset($tree['children'][$index]);
}
}
}
if (!$tree['children']) unset($tree['children']);
return $tree;
}