Generate infinitely classified structures

巴扎黑
Release: 2016-11-22 09:12:13
Original
1198 people have browsed it

生成无限分类的结构

public function get_tree_1(array $list = array())
{
$root = array();
$node = array();

foreach ($list as $k => $v) {

list($id, $pid, $name, $path) = array_values($v);
$node[$id] = $v;

if(isset($node[$pid])) {
$node[$pid]['child'][$id] = &$node[$id];
}

if($pid == 0) {
$root[$id] = &$node[$id];
}

}

return $root;
}


Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template