php代码如下:
$tree = array(); foreach ($list as $id => $row) { $pid = $row->pid; if ($pid == 0) { $tree[] = &$list[$id]; } else if (isset($list[$pid])) { $parent = &$list[$pid]; $parent->children[] = &$list[$id]; // 增加 children 属性标识子分类列表 } }
上一篇:PHP中加密解密类的示例分析
下一篇:怎么在PHP中查找数组中出现频率最多的10个数