PHP implements stepless recursive classification (ThinkPHP framework):
/** * 无级递归分类 * @param int $assortPid 要查询分类的父级id * @param mixed $tag 上下级分类之间的分隔符 * @return string $tree 返回的分类树型结构结果 * */ function recursiveAssort($assortPid, $tag = '') { $assort = M('goods_class')->where("class_pid = $assortPid")->field('class_id, class_name')->select(); foreach ($assort as $value) { $tree .= '<option value="' . $value['class_id'] . '">' . $tag . $value['class_name'] . '</option>'; $tree .= recursiveAssort($value['class_id'], $tag . ' '); } return $tree; }
The above is the content of PHP implementing stepless recursive classification (ThinkPHP framework). For more related content, please pay attention to the PHP Chinese website (www.php .cn)!