php FLEA中二叉树数组的遍历输出
程序员文章站
2022-04-19 23:25:07
但是要怎样遍历这个方法产生的二叉树数组呢?以下是我的做法: 复制代码 代码如下:
但是要怎样遍历这个方法产生的二叉树数组呢?以下是我的做法:
<?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
}
}
?>
复制代码 代码如下:
<?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
}
}
?>
上一篇: php 调试利器debug_print_backtrace()
下一篇: asp.net大文件下载