PHP - Search directory and subdirectories for specific file?
<p>How can I search a specific directory and its subdirectories for a specific file?</p>

<p>What I've tried are the following two functions:</p>

<pre><code>function getImageDirectory($ipaPath) {
    $oDirectory = new RecursiveDirectoryIterator($ipaPath);
    $oIterator = new RecursiveIteratorIterator($oDirectory);
    foreach($oIterator as $oFile) {
        if ($oFile-&gt;getFilename() == 'info.plist') {
           return $oFile-&gt;getPath();
        }
    }
}
</code></pre>

<p>EDIT: This one works, just as well as the answer bellow! My example above return the directory of the file you are looking for, in this case "info.plist".</p>

<p>EDIT2: Thanks for the down votes! If someone would have asked a similar question it would have shown when I wrote the title. But nothing for PHP. So if I search for the wrong thing, not using developer language it shouldn't be down voted! And now someone with my low php skills might find an answer to this question! Is stackoverflow only for PRO's or for anyone that needs help?</p>
