Question : PHP Recursive function not returning array values

I am writing an update to the google xml sitemap plugin for wordpress which whill allow users to exclude pages and subpages.

i have an array with 2 arrays inside, items, and parents
i wrote a recursive function that checks all items marked as parents for children and if the row count is not 0 then checks those children for children and so on.for each child it should add another entry into the items subarray and if i add a print_r during the while loop of my function i can see that it adds the items to the array. But when i try to loop through the array after all the recursion is done none of the children appear.

here is my code so far
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
<?php 


function get_all_children($list, $array){
	$child_sql = "SELECT DISTINCT wizard_posts.ID as id FROM wizard_posts WHERE wizard_posts.post_parent IN  ('".$list."') AND wizard_posts.post_status =  'publish'";
	$children = mysql_query($child_sql);
	while($my_c = mysql_fetch_array($children)){
		$parent_check .= $my_c['id'].',';
		$my_exclude['items'][$my_c['id']] = $my_c['id'];
	}		
	if(mysql_num_rows($children)!=0){
	get_all_children($parent_check, $my_exclude);
	}
	
	return $my_exclude;
}
$my_exclude = array(
	'items' => array(),
	'parents' => array()
);

$my_sql = "SELECT post_id as id, meta_value as value FROM wizard_postmeta WHERE meta_key='sitemap_exclude' AND meta_value in ('exclude', 'exclude_child')";
$my_result = mysql_query($my_sql);
while($my_v = mysql_fetch_assoc($my_result)){
	if($my_v['value']=='exclude_child'){
		$my_exclude['items'][$my_v['id']] = $my_v['id'];
		$my_exclude['parents'][$my_v['id']] = $my_v['id'];
	} else {
		$my_exclude['items'][$my_v['id']] = $my_v['id'];
	} 

}
foreach($my_exclude['parents'] as $parents){
	$parent_list .= $parents.',';
}
get_all_children($parent_list, $my_exclude);

foreach($my_exclude['items'] as $items){
	$my_exclude_list .= $items.",";
}
echo "<br>".$my_exclude_list."<br><br>";

?>

Answer : PHP Recursive function not returning array values

1:
2:
3:

function get_all_children($list, &$array){
Random Solutions  
 
programming4us programming4us