list ul recursive php
/**
* @param array $array
* @param array $classes
* @param int $level
* @return string
*/
function buildHtmlList($array,$classes='',$level=0)
{
$out = '<ul>';
if(!empty($classes)) {
$out = '<ul'.$classes[$level].'>';
}
foreach($array as $key => $value) {
if( is_array($value) ) {
$i = $level+1;
$out .= "<li>" . $key ;
$out .= $this->buildHtmlList($value,$classes,$i);
$out .= '</li>';
continue;
} else {
$out .= "<li>" . $array[$key] . "</li>";
}
}
$out .= "</ul>";
return $out;
}