Below is the structure of an array I have. I have two questions:
- How can I get the position of an array within an array?
For example, how would I get the position of array with element [post_id] => 2782
within [2772] => Array
(the answer should be 4)?
- How can I get the number of children arrays within an array?
For example, how would I get the number of children arrays for the array with element [post_id] => 2779
(the answer should be 2)?
Array
(
[2772] => Array
(
[post_id] => 2772
[children] => Array
(
[0] => Array
(
[post_id] => 2774
[children] => Array
(
[0] => Array
(
[post_id] => 2779
[children] => Array
(
[0] => Array
(
[post_id] => 2782
[children] => Array
(
)
)
[1] => Array
(
[post_id] => 2781
[children] => Array
(
)
)
)
)
[1] => Array
(
[post_id] => 2780
[children] => Array
(
[0] => Array
(
[post_id] => 2784
[children] => Array
(
)
)
)
)
)
)
[1] => Array
(
[post_id] => 2775
[children] => Array
(
)
)
[2] => Array
(
[post_id] => 2776
[children] => Array
(
)
)
)
)
)