The following is an array of 10
Array (ten) {[0] = = Array (5) {["id"] = + string (1) "1" ["pid"] = + string (1) "0" ["title"] + = string (6 "Discussion" ["Sort"] + string (1) "0" ["siatus"] = + string (1) "0"} [1] = = Array (5) {["id"] + = string (1 ) "2" ["pid"] = + string (1) "0" ["title"] + string (6) "Download" ["sort"] + = string (1) "0" ["siatus"] = String (1) "0"} [2] = = Array (5) {["id"] + = string (1) "3" ["pid"] = = string (1) "0" ["title"] = = St Ring (9) "Official area" ["sort"] + + string (1) "0" ["siatus"] = + string (1) "0"} [3] = = Array (5) {["id"] = s Tring (1) "4" ["pid"] = + string (1) "1" ["title"] + string (12) "Help to communicate" ["Sort"] + string (1) "0" ["Siat US "] = string (1)" 0 "} [4] = = Array (5) {[" id "] + = string (1)" 5 "[" pid "] = string (1)" 1 "[" title " ] = + string (12) "Technology sharing" ["sort"] and + string (1) "0" ["siatus"] = + string (1) "0"} [5] = + Array (5) {[" ID "] + = string (1)" 6 " ["pid"] = + string (1) "2" ["title"] = + string (9) "ebook" ["sort"] = + string (1) "0" ["siatus"] = str ING (1) "0"} [6] = = Array (5) {["id"] + = string (1) "7" ["pid"] = = string (1) "2" ["title"] + = string (6) "Software" ["sort"] + + string (1) "0" ["siatus"] = + string (1) "0"} [7] = = Array (5) {["id"] + = string (1) "8" ["pid"] = + string (1) "3" ["title"] + string (6) "Feedback" ["sort"] = + string (1) "0" ["siatus"] =&G T String (1) "0"} [8] = = Array (5) {["id"] + = string (1) "9" ["pid"] = = string (1) "1" ["title"] = = str ING (12) "Comprehensive discussion" ["Sort"] + string (1) "0" ["siatus"] = + string (1) "0"} [9] = = Array (5) {["id"] = String (2) "Ten" ["pid"] + string (1) "3" ["title"] = + string (12) "Program release" ["sort"] + = string (1) "0" ["si ATUs "] + = string (1)" 0 "}}
PID 0 is a top-level navigation with 3 id为0,1,2
讨论 下载 官方区
PID is not 0 is the sub-navigation has 7 is id为3,4,5,6,7,8,9
求助交流 技术分享 电子书 软件 反馈 综合讨论 程序发布
The PID of the sub-navigation is the ID of the top navigation. 讨论
求助交流 技术分享 综合讨论
Now it is necessary to write a function parameter that is the 10 heap array required to return an array $return
$return [' top '] is those top-level navigation array 3 array
Array (3) {.... Top Navigation ' Discussion download official area array:}
$return [' child '] is what those sub-navigation arrays Note is also the 3 array that corresponds to the top-level array
Array (3) {
[0] = = Array (3) {...... Help Exchange Technology share a comprehensive discussion array.}
[1] = = Array (2) {...... e-book Software array:}
[2] = = Array (2) {...... Feedback program published array:}
}
Array 1 belongs to the sub-navigation array of the discussion array
Array 2 is a sub-navigation array of the downloaded array
Array 3 is the sub-navigation array of the official area array
Reply content:
The following is an array of 10
Array (ten) {[0] = = Array (5) {["id"] = + string (1) "1" ["pid"] = + string (1) "0" ["title"] + = string (6 "Discussion" ["Sort"] + string (1) "0" ["siatus"] = + string (1) "0"} [1] = = Array (5) {["id"] + = string (1 ) "2" ["pid"] = + string (1) "0" ["title"] + string (6) "Download" ["sort"] + = string (1) "0" ["siatus"] = String (1) "0"} [2] = = Array (5) {["id"] + = string (1) "3" ["pid"] = = string (1) "0" ["title"] = = St Ring (9) "Official area" ["sort"] + + string (1) "0" ["siatus"] = + string (1) "0"} [3] = = Array (5) {["id"] = s Tring (1) "4" ["pid"] = + string (1) "1" ["title"] + string (12) "Help to communicate" ["Sort"] + string (1) "0" ["Siat US "] = string (1)" 0 "} [4] = = Array (5) {[" id "] + = string (1)" 5 "[" pid "] = string (1)" 1 "[" title " ] = + string (12) "Technology sharing" ["sort"] and + string (1) "0" ["siatus"] = + string (1) "0"} [5] = + Array (5) {[" ID "] + = string (1)" 6 " ["pid"] = + string (1) "2" ["title"] = + string (9) "ebook" ["sort"] = + string (1) "0" ["siatus"] = str ING (1) "0"} [6] = = Array (5) {["id"] + = string (1) "7" ["pid"] = = string (1) "2" ["title"] + = string (6) "Software" ["sort"] + + string (1) "0" ["siatus"] = + string (1) "0"} [7] = = Array (5) {["id"] + = string (1) "8" ["pid"] = + string (1) "3" ["title"] + string (6) "Feedback" ["sort"] = + string (1) "0" ["siatus"] =&G T String (1) "0"} [8] = = Array (5) {["id"] + = string (1) "9" ["pid"] = = string (1) "1" ["title"] = = str ING (12) "Comprehensive discussion" ["Sort"] + string (1) "0" ["siatus"] = + string (1) "0"} [9] = = Array (5) {["id"] = String (2) "Ten" ["pid"] + string (1) "3" ["title"] = + string (12) "Program release" ["sort"] + = string (1) "0" ["si ATUs "] + = string (1)" 0 "}}
PID 0 is a top-level navigation with 3 id为0,1,2
讨论 下载 官方区
PID is not 0 is the sub-navigation has 7 is id为3,4,5,6,7,8,9
求助交流 技术分享 电子书 软件 反馈 综合讨论 程序发布
The PID of the sub-navigation is the ID of the top navigation. 讨论
求助交流 技术分享 综合讨论
Now it is necessary to write a function parameter that is the 10 heap array required to return an array $return
$return [' top '] is those top-level navigation array 3 array
Array (3) {.... Top Navigation ' Discussion download official area array:}
$return [' child '] is what those sub-navigation arrays Note is also the 3 array that corresponds to the top-level array
Array (3) {
[0] = = Array (3) {...... Help Exchange Technology share a comprehensive discussion array.}
[1] = = Array (2) {...... e-book Software array:}
[2] = = Array (2) {...... Feedback program published array:}
}
Array 1 belongs to the sub-navigation array of the discussion array
Array 2 is a sub-navigation array of the downloaded array
Array 3 is the sub-navigation array of the official area array
function getFormate($arr){ $top = $child = array(); foreach($arr as $val){ if($val['pid'] == 0){ $top[] = $val; }else{ $child[ $val['pid'] ][] = $val; } } return array('top' => $top, 'child' => array_values($child) );}
This should be what you need.