How PHP iterates through a multidimensional array of crosses and gives its ID and PID (parent key ID)
PHP Code
Array (7) {[1] = = Array (5) {["id"] + = string (1) "1" ["pid"] = + string (1) "0" ["name"] + = string (15 "Assetmanagement" ["title"] + = string (12) "Asset Management" ["submenu"] = = Array (1) {[0] = = string (0) ""} } [2] = = Array (5) {["id"] = + string (1) "2" ["pid"] = + string (1) "0" ["Name"] + string "System Settings "[" title] + = string (12) "System Settings" ["submenu"] = + Array (1) {[0] = = string (0) ""}} [3] =& Gt Array (5) {["id"] + = string (1) "3" ["pid"] + string (1) "0" ["Name"] + string () "Management" ["Tit Le "] = string (12)" Background Management "[" submenu "] = = Array (1) {[0] = = string (0)" "}} [4] = = Array (5) { ["id"] = + string (2) "One" ["pid"] = + string (1) "1" ["name"] + = string (9) "HZ" ["title"] + string (15) "HZ" ["submenu"] + = Array (1) {[0] = = string (0) ""}} [5] = = Array (5) {["id"] + = string (2) " ["pid"] = = String (1) "1" ["name"] + = string (9) "XM" ["title"] = + string (+) "XM" ["submenu"] = = Array (1) {[0 ] = = String (0) ""}} [6] = = Array (5) {["id"] + = string (1) "9" ["pid"] = + string (1) "1" ["Name" ] = + string (9) "BJ" ["title"] = + string ("BJ" ["submenu"] + = Array (1) {[0] = string (0) ""} } [7] = = Array (5) {["id"] = + string (1) "4" ["pid"] + string (1) "1" ["Name"] + string "Tot" Almanagement "[" title] + = string (15) "Total Management" ["submenu"] + = Array (3) {[0] = = Array (5) {["id"] = = String (1) "5" ["Name"] + string ("PC" ["menu_id"] = + string (1) "4" ["title"] = = St Ring (+) "PC" ["Access"] + int (1)} [1] = = Array (5) {["id"] + = string (1) "6" ["N Ame "] + string (1)" BJB "[" menu_id "] and" + string "[+]" 4 "[" title "] + string (+)" BJB "[" Acces S "] = Int (1)} [2] = = Array (5) {["id"] = + string (1) "7" ["name"] + = string (+) "select" ["menu_id"] = > string (1) "4" ["title"] + string (15) "Query" ["access"] + = Int (1)}}}} How do you write the above array as follows? Array (3) {[1] = = Array (5) {["id"] + = string (1) "1" ["pid"] = + string (1) "0" ["name"] + = string (15) "Assetmanagement" ["title"] + = string (12) "Asset Management" ["submenu"] = + Array (4) {[1] = = Array (5) { ["id"] + = string (2) "One" ["pid"] = + string (1) "1" ["name"] = + string (9) "HZ" ["title"] = = string (1) "HZ" ["submenu"] = = Array (+) {[0] = = string (0) "" }} [2] = = Array (5) {["id"] + = string (2) "Ten" ["pid"] = + string (1) "1" ["name"] + = string (9) "XM" ["title"] + string (+) "XM" ["submenu"] = = Array (1) {[0] =&Gt String (0) ""}} [3] = = Array (5) {["id"] + = string (1) "9" ["pid" ] = + string (1) "1" ["name"] and + string (9) "BJ" ["title"] + string ("BJ" ["Sub Menu "] = = Array (1) {[0] = = string (0)" "}} [4] = = Array (5) {["id"] + = string (1) "4" ["pid"] = + string (1) "1" ["Name"] and "+ string" total Management "[" title] + = string (15) "Total Management" ["submenu"] + = Array (3) {[0] = arr Ay (5) {["id"] + = string (1) "5" ["name"] + = string ("PC" ["menu_id"] = = String (1) "4" ["title"] + string (+) "PC" ["Access"] + int (1)} [1] = = Array (5) {["id"] + = string (1) "6" ["name"] + = string "BJB" ["Menu_id "] + string (1)" 4 "[" title "] = + string" BJB "[" Access "] + int (1) } [2] = = Array (5) {["id"] = + string (1) "7" ["name"] + = string (1 6) "Select" ["menu_id"] + = string (1) "4" ["title"] + string (15) "Query" [ "Access" = + int (1)}}}} [2] = = Array (5) { ["id"] = + string (1) "2" ["pid"] = + string (1) "0" ["name"] + = string (+) "Systemsettings" ["title"] => ; String (12) "System Settings" ["submenu"] + = Array (1) {[0] = = string (0) ""}} [3] = = Array (5) {["id"] => ; String (1) "3" ["pid"] + string (1) "0" ["Name"] and "Management" ["title"] + string (12) "Background management "[" submenu "] + = Array (1) {[0] = = string (0)" "}}}