PHP Simple implementation of the infinite classification of tree list method, PHP classification tree list
In this paper, a simple way to implement an infinite classification tree list is described in PHP. Share to everyone for your reference. Specific as follows:
$items = Array (1 = = Array (' id ' = = 1, ' pid ' = 0, ' name ' = ' Jiangxi '), 2 = = Array (' id ' = = 2, ' pid ' => ; 0, ' name ' = ' Heilongjiang Province '), 3 = = Array (' id ' = 3, ' pid ' = = 1, ' name ' = ' Nanchang '), 4 = = Array (' id ' = = 4, ' P ID ' = 2, ' name ' = ' Harbin ', 5 = = Array (' id ' = 5, ' pid ' = = 2, ' name ' = ' Jixi '), 6 = = Array (' id ' = > 6, ' pid ' = 4, ' name ' = = ' Xiangfang District '), 7 = = Array (' id ' = = 7, ' pid ' = 4, ' name ' = ' Nangang '), 8 = AR Ray (' id ' = + 8, ' pid ' = + 6, ' name ' = = ' and Hing Road '), 9 = = Array (' id ' = = 9, ' pid ' = 7 ', ' name ' = ' West big straight Street '), The array (' id ' = ' + ', ' pid ' = + 8, ' name ' = ' + ') ', ' + = ' array (' id ' = ' = ', ' pid ' = ' = 9 ', ' name ' = ' Harbin Institute of Technology '), A. Array (' id ' = +, ' pid ' = 8, ' name ' = ' harbin Normal University '), and array (' id ' = 13, ' PID ' = = 1, ' name ' = ' Ganzhou '), + = array (' id ' = ' = ', ' pid ' = ' = ') ', ' name ' = ' Gan County '), + = Array (' I d ' = +, ' pid ' => The ' name ' = ' Yudu County '), and the array (' id ' = ' + ', ' pid ' = ' + ', ' name ' = ' Mao Dian zhen '), + = array (' id ' = The ' pid ' = +, ' name ' + ' Ota township ', and Array (' id ' = ' + ', ' pid ' = + ', ' name ' = ' righteousness village '), Rray (' id ' = +, ' pid ' = ' + ', ' name ' = ' Shang Ba village '), ' + ' (' id ' = ' + ', ' pid ' = ' 0 ', ' name ' = ' Guangdong ' ), + = array (' id ' = +, ' pid ' = = ', ' name ' = ' Guangzhou '),); $t = Array (); foreach ($items as $id + $item) {if ($item [' pid ']) {$items [$item [' PID ']][$item [' id ']] = & $items [$item [' ID ' ]]; $t [] = $id; }} foreach ($t as $u) {unset ($items [$u]);} echo ""; Print_r ($items);
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/974660.html www.bkjia.com true http://www.bkjia.com/PHPjc/974660.html techarticle PHP Simple implementation of the infinite classification of the tree list of methods, PHP classification tree list In this paper, we describe the simple implementation of the infinite classification of the tree list of the method. Share to everyone for your reference. Specific ...