I'm working on a class, and I have this function. I don't know where the mistake is but function doesn't "return" anything at all, yet if I change the "return" for an "echo" it does display the correct result, and the logic seems to be working, so I'm a little confused..Thanks in advance.
    public function myFunction(array $haystack, $needle)
{   
    foreach($haystack as $key => $value )
    {            
        if (is_array($value))
        {  
             $this->myFunction($value, $needle);
        }
        else
        {  
            if($key == $needle) 
            { 
                return $value; 
                break;
            }
        }   
    }
 
    