Here, try this program
//where "directory" is the name of the directory through
//which php will search, including subdirectories.
searchfolder ("directory");
function searchfolder ($folder) {
//go through all the contents of the folder
$dir = opendir ($folder);
while (($file = readdir ($dir)) !== FALSE) {
if ($file != "." && $file != "..") {
if (is_dir ($folder."/".$file))
searchfolder ($folder."/".$file);
elseif ($file == "test.txt")
processfile ($folder."/".$file);
}
}
}
function processfile ($file) {
//here, enter what you want to happen with each file, given
//the file's name and path relative to this script
}
Hope that helps you out 🙂