查找根索引陣列的深度I有像從特定節點
Array
(
[0] => Array
(
[id] => 81
[cata_key] => 908cbbcb86a1cf64b67c96ff
[cata_name] => Lunch
[app_key] => 2fabc0d9447c6375657dead4
[parentid] => 0
[subcategories] => Array
(
)
)
[1] => Array
(
[id] => 80
[cata_key] => baac98b4e73c05ebbf45bdc6
[cata_name] => Break Fast
[app_key] => 2fabc0d9447c6375657dead4
[parentid] => 0
[subcategories] => Array
(
[0] => Array
(
[id] => 82
[cata_key] => 5970b7afc450ef3b24573de9
[cata_name] => Rise Products
[app_key] => 2fabc0d9447c6375657dead4
[parentid] => 80
[subcategories] => Array
(
[0] => Array
(
[id] => 83
[cata_key] => 82e36d8f821e14fc8db1d4da
[cata_name] => Dosha
[app_key] => 2fabc0d9447c6375657dead4
[parentid] => 82
[subcategories] => Array
(
[0] => Array
(
[id] => 84
[cata_key] => 49730020d850439dd7de8747
[cata_name] => Masala Dosha
[app_key] => 2fabc0d9447c6375657dead4
[parentid] => 83
[subcategories] => Array
(
)
)
)
)
)
)
)
)
)
陣列我想從一個特定的內部陣列ID找到根索引的子陣列的深度。例如,我想從parentid = 0中找到根索引數組的深度,它應該是1.來自parentId = 0/80/82/83的根索引子數組的深度應該是4.
其實我的目的是限制數組的深度。應該有一個深度限制。所以當任何人試圖向這個數組添加一個子數組時,我們應該找出當前的數組深度。例如,數組深度限制爲4,並且任何一個嘗試在cata_name = Masala Dosha下添加一個子數組,深度已經達到,並且不應允許添加新的子數組。但在同一時間,他可以添加[cata_name] =>午餐下一個子陣列,因爲其深度只有1和深度極限是4
需要FUNC該輸入0返回1,80返回2,83返回圖3,84return 4 ?? – 2013-04-24 04:28:08
無0返回0或80返回4,83返回4和83返回4 – SunilKumar 2013-04-24 04:38:25
在構建此樹時,您不能只添加預先計算的級別值嗎? – zerkms 2013-04-24 04:45:20