Thursday, 5 September 2013

php merge same keys in multidimensional array

php merge same keys in multidimensional array

I have a multidimensional array like below(figure 1). I just want to push
all the sub array keys which are equal to parent array key as key values.
As an example lets say, parent key is 23. and 23 has a child key 24. child
key 24 has sub child keys (25,26,27....) and also sub child key may have
another child keys. So what I want is to push all the child, subchild,
subsubchild... to parent key 23. so it will be like "Array( [23]=> Array
([24]=> Array ( [25] => [26] => [27] => Array ( [28] = > [29] =>) ) )"
I really appreciate if someone can come up with a solution for this.
Thanks a lot..
Figure 1
Array ( [
18] => Array (
[1] =>
[14] =>
)
[23] => Array (
[24] => Array (
[25] =>
[26] => Array (
[27] =>
[28] =>
)
)
)
)

No comments:

Post a Comment