I am completely stumped on what appears to be a trivial problem.
I have this function:
function findCategoryNameInTree($id, $tree) {
foreach($tree as $branch) {
if ($branch['category_id'] == $id) {
echo $branch['name'];//works
print_r($branch['name']);//works
//return($branch['name']); //returns nothing
return $branch['name'];//fix this line per feedback still no return value
} else {
if(count($branch['children']) > 0) {
findCategoryNameInTree($id,$branch['children']);
}
}
}
}
I can't figure out for the life of me why it's not returning anything.
Please help!
Edit Here's how I call my function
//what I really want to do
$primgenre = findCategoryNameInTree($cat_id,$category_tree['children']);
//but this doesnt work either
echo $primgenre;
//nor this
print_r($pringenre);
findCategoryNameInTreefunction and how is it that you determine that function's return value is something that's wrong and not your interpretation of function's return value.