I have a multidimensional array with following values
$array = array(
0 => array (
"id" => 1,
"parent_id" => 0
),
1 => array (
"id" => 2,
"parent_id" => 1
),
2 => array (
"id" => 3,
"parent_id" => 1,
)
3 => array (
"id" => 4,
"parent_id" => 0
)
4 => array (
"id" => 5,
"parent_id" => 3
)
);
I want to find the count of children for particular id. In my case, I want the results to be like
find_children($array, 1);
// output : 2
find_children($array, 3);
// output : 1
I know this is done by using for loop. Is there any PHP array functions exist for this function?