I am attemptting to attach a small CMS to a website I am creating. However I have come across a small problem. The CMS uses PHP functions for inserting menus, these PHP func
This would be a excellent example of the use of recursion. An array (with sub-arrays within it) defines each level, and a function loops, calling itself whenever it finds a new array to process. As long as the function cleans up appropriately (closing the &
), it's largely automatic.
';
foreach($tree as $item) {
if (is_array($item)) {
olLiTree($item);
} else {
echo '- ', $item, '
';
}
}
echo '';
}
olLiTree($tree); // kick off from the top level