PHP unlimited classification table to div reference URL http://www.qunfei.com/htmls/webdevelop/php/2012/0116/819.htmlfunction dafenglei_arr ($ m, $ id) {global & nbsp; $ class_arr; PHP unlimited classification table to div
Reference URL
Http://www.qunfei.com/htmls/webdevelop/php/2012/0116/819.html
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
if($class_arr[$i]['classFID']==$id){
echo "\n";
echo "
".$n."|--".$class_arr[$i]['className'].$m."\n";
echo "\n";
dafenglei_arr($m+1,$class_arr[$i]['classid']);
}
}
}
The output format is
Topic 1
Topic 1-1
Topic 1-2
Topic 1-3
Topic 1-3-1
Convert
Topic 1
- Topic 1-1
- Topic 1-2
- Topic 1-3
... And so on.
------ Solution --------------------
$ Ar = array (
2 =>
Array (
'Classid' => '6 ',
'Classfid' => '0 ',
'Classname' => 'topic 1 ',
),
1 =>
Array (
'Id' => '7 ',
'Classfid' => '6 ',
'Classname' => 'column 1-1 ',
),
0 =>
Array (
'Classid' => '10 ',
'Classfid' => '7 ',
'Classname' => 'column 1-1-1 ',
),
);
Echo'
';
Foreach ($ ar as $ item ){
If ($ item ['classfid'] = 0) $ deep = 0;
$ T = substr_count ($ item ['classname'], '-');
If ($ t <$ deep) echo'
';
If ($ t> $ deep) echo'
';
Echo'
- '. $ Item ['classname'];
$ Deep = $ t;
}
While ($ deep --) echo'
';