1
category: {
1: {
id: 1,
category_id: 7,
name: "N&E",
parent: 0,
created_at: "2015-06-17 01:36:03",
…
}
2: {
id: 2,
category_id: 8,
name: "Vauniya",
parent: 1,
created_at: "2015-06-17 01:36:03",
…
}
3: {
id: 3,
category_id: 9,
name: "MANNAR TOWN",
parent: 2,
created_at: "2015-06-17 01:36:03",
…
}
4: {
id: 4,
category_id: 10,
name: "KANDASAMY CHANDRAMURALI",
parent: 3,
created_at: "2015-06-17 01:36:04",
…
}
5: {
id: 5,
category_id: 11,
name: "",
parent: 4,
created_at: "2015-06-17 01:36:04",
…
}
6: {
id: 6,
category_id: 12,
name: "MATHUSHAN STORE",
parent: 5,
created_at: "2015-06-17 01:36:04",
…
}
7: {
id: 7,
category_id: 13,
name: "E.H PREMACHANDRAN",
parent: 6,
created_at: "2015-06-17 01:36:04",
…
}
8: {
id: 8,
category_id: 14,
name: "56870",
parent: 7,
created_at: "2015-06-17 01:36:04",
…
}
9: {
id: 9,
category_id: 18,
name: "E & D",
parent: 7,
created_at: "2015-06-17 01:36:04",
…
}
10: {
id: 10,
category_id: 19,
name: "PUNITHA PAVAN HOTEL",
parent: 9,
created_at: "2015-06-17 01:36:04",
…
}
}
使用此陣,我想獲得數組這樣我有數組對象,我想跟隨輸出在PHP
mapArray(
array(
array(
'children' => array(
array(
'children' => array(
array(
'children' => array(
array(
'children' => array()
),
array(
'children' => array()
)
)
),
array(
'children' => array()
)
)
),
array(
'children' => array()
)
)
),
array(
'children' => array()
),
array(
'children' => array()
)
)
);
你能告訴什麼是孩子的孩子之間的關係,按您的陣列 –
這是關係。有像 區域(category_id = 0) - > area(category_id = 1) - >地域(category_id = 3) - > asm(category_id = 4)...-> outlet(category_id = 19)這 – Sriya
存在一個ID 1:{ ID:1, CATEGORY_ID:7, 名: 「N&E」, 父:0 } 和這個ID可以是另一個的父 – Sriya