php scandir --> search for files/directories
<p>I searched before I ask, without lucky..</p>

<p>I looking for a simple script for myself, which I can search for files/folders. Found this code snippet in the php manual (I think I need this), but it is not work for me.</p>

<p>"Was looking for a simple way to search for a file/directory using a mask. Here is such a function. </p>

<p>By default, this function will keep in memory the scandir() result, to avoid scaning multiple time for the same directory."</p>

<pre><code>&lt;?php 
function sdir( $path='.', $mask='*', $nocache=0 ){ 
    static $dir = array(); // cache result in memory 
    if ( !isset($dir[$path]) || $nocache) { 
        $dir[$path] = scandir($path); 
    } 
    foreach ($dir[$path] as $i=&gt;$entry) { 
        if ($entry!='.' &amp;&amp; $entry!='..' &amp;&amp; fnmatch($mask, $entry) ) { 
            $sdir[] = $entry; 
        } 
    } 
    return ($sdir); 
} 
?&gt;
</code></pre>

<p>Thank you for any help,</p>

<p>Peter</p>
