I'm creating an array outside of my PHP function and calling global inside the function but my function fails to see the array. The function is also called recursively. Any idea what I'm doing wrong?
$node_types = array( 1 => 'testproject',
2 => 'testsuite',
3 => 'testcase');
function get_subtree($node_id,&$node_list) {
global $node_types;
foreach ($node_types as $key) {
echo("node_types: " . $key . "<BR>");
}
....
get_subtree($node_id,$node_list);
}
My error:
Notice: Undefined variable: node_types in ...
Thanks