日期:2014-05-17 浏览次数:20468 次
function dafenglei_arr($m,$id)
{
global $class_arr;
global $ppid;
if($id=="") $id=0;
$n = str_pad('',$m,'-',STR_PAD_RIGHT);
$n = str_replace("-"," ",$n);
for($i=0;$i<count($class_arr);$i++){
if($class_arr[$i]['classFID']==$id){
echo "<tr>\n";
echo "<td height=\"28\" class=\"font\">".$n."|--<a href=\"?action=edit&id=".$class_arr[$i]['classid']."\">".$class_arr[$i]['className'].$m."</a></td>\n";
echo "</tr>\n";
dafenglei_arr($m+1,$class_arr[$i]['classid']);
}
}
}
$ar = array (<ul><li>栏目一<ul><li>栏目1-1<ul><li>栏目1-1-1</li></ul></li></ul>
2 =>
array (
'classid' => '6',
'classfid' => '0',
'classname' => '栏目一',
),
1 =>
array (
'id' => '7',
'classfid' => '6',
'classname' => '栏目1-1',
),
0 =>
array (
'classid' => '10',
'classfid' => '7',
'classname' => '栏目1-1-1',
),
);
echo '<ul>';
foreach($ar as $item) {
if($item['classfid'] == 0) $deep = 0;
$t = substr_count($item['classname'], '-');
if($t < $deep) echo '</li></ul>';
if($t > $deep) echo '<ul>';
echo '<li>'.$item['classname'];
$deep = $t;
}
while($deep--) echo '</li></ul>';