有人可以帮我把这段代码翻译成智能友好,取自这里
function outputCategories($categories, $startingLevel = 0)
{
foreach ($categories as $key => $category)
{
if (count($category['children']) > 0)
{
echo '<li><a title="'.$category['name'].'" href="'.$category['url'].'">'.$category['name'].'</a><ul>';
outputCategories($category['children'], $startingLevel+1);
echo "</li>";
}
else
{
echo '<li><a title="'.$category['name'].'" href="'.$category['url'].'">'.$category['name'].'</a></li>';
}
}
echo "</ul>";
return self;
}
我可以使用以下行生成单级类别:
{foreach from=$hsitemap item=c name=hsitemap}
{if $c.parent_id ==0 }
<li><h2><a title="{$c.site_name}" href="{$c.site_url}">{$c.site_name}</a></h2><ul>
{foreach item=d from=$c.children name=sitemap}
<li><a title="{$d.site_name}" href="{$d.site_url}">{$d.site_name}</a></li>
{/foreach}
{else}
<li><h2><a title="{$c.site_name}" href="{$c.site_url}">{$c.site_name}</a></h2><ul>
{/if}
</ul>
</li>
{/foreach}
</ul>
但现在我有一个多层次的要求,请帮我解决这个问题。