Here is a recursive function that I wrote to search a file-system to a child depth defined by $depth.Could it be optimized more?function stringSearch($working_dir,&$results_array,$depth){    global $search_string;    global $dir_count;    global $file_count;    global $working_url;    global $max_depth;    if($max_depth>=($depth+1))    {        $dir_array = glob($working_dir.'/*', GLOB_ONLYDIR);        foreach($dir_array as $new_path)        {            stringSearch($new_path,$results_array,($depth+1));            $dir_count++;        }    }    $handle = opendir($working_dir);    while ($file = readdir($handle))     {        if(is_file($working_dir.'/'.$file))        {            if(stripos(str_replace('_',' ',$file),$search_string))                $results_array[] = array('file'=>$file,'path'=>$working_dir,'url'=>$working_url.str_replace($_SERVER[DOCUMENT_ROOT],'',$working_dir));            $file_count++;        }    }    return;}
PHP - Optimizing Recursive Method
php;recursion;file system