php function returns empty string. echo prints the string properly;
<p>I am completely stumped on what appears to be a trivial problem.</p>

<p>I have this function:</p>

<pre><code>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']) &gt; 0) {
                findCategoryNameInTree($id,$branch['children']);
            }
        }

    }
}
</code></pre>

<p>I can't figure out for the life of me why it's not returning anything.</p>

<p>Please help!</p>

<p><strong>Edit</strong>
Here's how I call my function</p>

<pre><code>//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);
</code></pre>
