这里我使用Tree结构数组作为我的php项目。在这个数组中,我想在编程中找到数组级别,并将数组节点级别更新为数组中的一个字段。 这是我的阵列:
Array(
[id] => test1
[data] => Array([balance] => 0 )
[has_children] => 1
[children] => Array(
[0] => Array
([id] => test2
[data] => Array([balance] => 45)
[has_children] =>
)
[1] => Array(
[id] => test3
[data] => Array([balance] => 78)
[has_children] =>
)
[2] => Array(
[id] => test55
[data] => Array([balance] => 0)
[has_children] => 1
[children] => Array(
[0] => Array(
[id] => test45
[data] => Array([balance] => 90)
[has_children] =>
)
)
)
[3] => Array(
[id] => test567
[data] => Array([balance] => 123)
[has_children] =>
)
[4] => Array(
[id] => test79
[data] => Array([balance] => 34)
[has_children] =>
)
)
)
动态创建的数组。所以我无法找到阵列深度和每个节点级别。例如:test1为1级,test2为2级,test3为2级,test55为2级,test 45为3级,test567& test79为2级。