但是要怎樣遍歷這個方法產生的二叉樹數組呢?以下是我的做法:
復制代碼 代碼如下:
<?php
function preTree($cat){
foreach ($cat as $c){
?>
<p><a href="http://<?=$c['poper_site']?>"><?=$c['poper']?></a>:<?=t($c['content'])?></p>
<?php if(isset($c['childrens'])){?>
<ul>
<?php foreach ($c['childrens'] as $s){?>
<li><p><a href="http://<?=$s['poper_site']?>"><?=$s['poper']?></a>:<?=t($s['content'])?></p>
<?php
if(isset($s['childrens'])){
?><ul><li><?php
$this->preTree($s['childrens']);
?></li></ul><?php
}
?>
</li>
<?php }?>
</ul>
<?php }?>
<?php
}
}
?>