Hi all,
After two hours of head scratching and googling - i'm stuck!
As per the title I'm trying to return an array that is built up as the function loops through. I want to only return the array variable on the else however it will not co-operate. It simply returns as blank away from the function, however within the else I can print_r it and shows as expected. It just simply won't return the array in the $open_array variable. Any ideas (or abuse) would be greatfully appreciated!
function find_parent($number, $open = false) {
if(isset($other_variable[$number])) {
foreach($other_variable[$number] as $val) {
$open[$val->id] = [$val->id;
$open = find_parent([$val->id, $open);
}
}
else {
return $open;
}
}
$open_array = find_parent($number);
print_r($open_array);