count($arr['children'], COUNT_RECURSIVE);
to get the total number of keys inside the original children key, however I'm wanting to filter out all but the keys named 'children.' I'm unsure the count_recursive works like this.
$arr = array (
'id' => '81',
'parent' => NULL,
'children' =>
array (
0 =>
array (
'id' => '173',
'parent' => '81',
),
1 =>
array (
'id' => '84',
'parent' => '81',
'children' =>
array (
0 =>
array (
'id' => '85',
'parent' => '84',
'children' =>
array (
0 =>
array (
'id' => '131',
'parent' => '85',
'children' =>
array (
0 =>
array (
'id' => '176',
'parent' => '131',
),
),
),
),
),
1 =>
array (
'id' => '174',
'parent' => '84',
),
2 =>
array (
'id' => '175',
'parent' => '84',
),
),
),
),
);
echo count($arr['children'], COUNT_RECURSIVE);
I'm trying to have it return 7, but because it's counting all keys, it returns 24. How could I do this?