Home >Backend Development >PHP Tutorial >ThinkPHP implements recursive stepless classification - less code, thinkphp recursive_PHP tutorial

ThinkPHP implements recursive stepless classification - less code, thinkphp recursive_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:45:49710browse

ThinkPHP implements recursive stepless classification - less code, thinkphp recursive

The specific code is as follows:

/**
*  无级递归分类
*  @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 . '&emsp;');
  }
  return $tree;
}

The above code is all about using ThinkPHP to implement recursive stepless classification. I hope you like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1039187.htmlTechArticleThinkPHP implements recursive stepless classification - less code, the specific code of thinkphp recursion is as follows: /*** Stepless recursion Category* @param int $assortPid The parent id of the category to be queried* @param mixed $tag on...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn