无限分级算法
<无详细内容>
<?php //无限分级分类 //来源: htttp://aiyooyoo.com header('Content-type:text/html; charset=UTF-8'); $conn = mysql_connect('localhost', 'root', '123456'); mysql_select_db('xsphp'); mysql_query('SET NAMES utf8'); $result = mysql_query('SELECT id,fid,name FROM cat ORDER BY id'); $rows = array(); while ($row = mysql_fetch_assoc($result)) { $rows[$row['id']] = $row; } $t = array(); foreach ($rows as $id => $item) { if ($item['fid']) { $rows[$item['fid']][$item['id']] = &$rows[$item['id']]; $t[] = $id; } } foreach($t as $u) { unset($rows[$u]); } print_r($rows);
精彩图集
精彩文章