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
A simple function is all you need.
function unorderedList($val)
{
if (is_array($val)) {
return '- ' .
implode('
- ',
array_map('unorderedList', $val)) .
'
';
} else {
return $val;
}
}
Test code:
$menu = array('Projects (Menu Level 1)',
array('Project 1 (Menu Level 2)',
'Project 2 (Menu Level 2)',
'Project 3 (Menu Level 2)'),
'News (Menu Level 1)',
'Contact (Menu Level 1)');
echo unorderedList($menu);