function printMenu($menuArray, $currentLevel) {
if (! isset($currentLevel)) {
$currentLevel = 1;
} else {
$currentLevel += 1;
}
$html = '<ul class="level-'.$currentLevel.'">';
foreach ($menuArray as $menuItem) {
$html .= "<li>";
$html .= "<a href=\"{$menuItem['link']}\">{$menuItem['title']}</a>";
if (!empty($menuItem['children'])) {
$html .= printMenu($menuItem['children'], $currentLevel);
}
$html .= "</li>";
}
$html .= '</ul>';
return $html;
}