An array of infinite polar classifications for PHP
Array (' id ' = = 1, ' name ' = ' name1 ', ' pid ' = 0), 2 = = Array (' id ' = = 2, ' name ' = = ' name2 ', ' pid ' = > 0), 3 = = Array (' id ' = 3, ' name ' = ' = ' name3 ', ' pid ' = = 1), 4-= array (' id ' = = 4, ' Name ' = ' name4 ', ' pid ' = ' 0 ', 5 = = Array (' id ' = + 5, ' name ' = ' name5 ', ' pid ' = = 3), 6 = = Array (' id ' = = 6, ' name ' = ' name6 ', ' pid ' = 3),); $str = gettree (0); $str = "" . $str. ""; Echo $str; function Gettree ($id, $spac =0) {$data = array (1 = = Array (' id ' = = 1, ' name ' = = ' name1 ', ' pid ' = 0 ), 2 = = Array (' id ' = = 2, ' name ' = = ' name2 ', ' pid ' = 0), 3 = = Array (' id ' = = 3, ' name ' = ' Name3 ', ' pid ' = 1), 4 = = Array (' id ' = 4, ' name ' = ' name4 ', ' pid ' = = 0), 5 =&G T Array (' id ' = = 5, ' name ' = ' name5 ', ' pid ' = 3), 6 = = Array (' id ' = = 6, ' name ' = = ' name6 ', ' pid ' = > 3),); $spac = $spac + 2; Static $str; foreach ($data as $k + $v) {if ($v [' pid '] = = $id) {$arr [] = $v; $str. = "" . Str_repeat ("", $spac). "| --" . $v [' name ']. ""; Gettree ($v [' id '], $SPAC); }} return $str;} ?>
http://www.bkjia.com/PHPjc/1079403.html www.bkjia.com true http://www.bkjia.com/PHPjc/1079403.html techarticle an array of infinite pole classifications for php? php$data = Array (1 = array (id = 1,name = name1,pid = 0), 2 = array (id = 2,name = name2,pid = 0), 3 = arr Ay (id = 3,name = name3,pid = 1), 4 = Array (id ...