beWhat if I needed to recursively search some directories in order to find a .something file?
I have this code so far:
$dir_iterator = new RecursiveDirectoryIterator('path/');
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $filename) {
if(strpos($filename, ".apk")){
$page->addToBody(substr($filename, 2)."</br>");
$filename = substr($filename, 2);
}
}
This works in returning the only .apk file in the directories, however I want to be able to find a specific file if more than one are found.
e.g. I want to say find all the filesnames that contain "hello" and end in .apk.
With Glob() i did this which worked great:
glob('./'path'/*{'Hello'}*.apk',GLOB_BRACE);
However its not recursive. and depends on the correct directory being specified. Any help would much appreciated.