I have a bunch of name-parentname pairs, that I\'d like to turn into as few heirarchical tree structures as possible. So for example, these could be the pairings:
Well, to parse into ULs and LIs, it would be something like:
$array = array (
'H' => 'G'
'F' => 'G'
'G' => 'D'
'E' => 'D'
'A' => 'E'
'B' => 'C'
'C' => 'E'
'D' => 'NULL'
);
recurse_uls ($array, 'NULL');
function recurse_uls ($array, $parent)
{
echo '';
foreach ($array as $c => $p) {
if ($p != $parent) continue;
echo '- '.$c.'
';
recurse_uls ($array, $c);
}
echo '
';
}
But I'd love to see a solution that doesn't require you to iterate through the array so often...