How to use PHP readdir to read files in directories outside of the root level and link?
<p>I am using a php include (side nav menu- where php script would be) that resides on the root level of my webserver. </p>

<p>I would like to use a php readdir or scandir to list the contents of a different folder on my server (/report_1) with links to those files excluding html, htm and xslt extensions. (or to just only include php extensions) </p>

<p>Currently I am using a readdir that only reads the contents of the current directory it resides in and returns links excluding certain file types.(see code below) </p>

<p>I would eventually like to have a php file in the include that lists and links to files outside the "include" root level. Any help would be very appreciated. </p>

<pre><code>&lt;?php

// These files will be ignored
$excludedFiles = array (
'excludeMe.file',
'excludeMeAs.well'
);

// These file extensions will be ignored
$excludedExtensions = array (
'html',
'htm',
'php'
);

// Make sure we ignore . and ..
$excludedFiles = array_merge($excludedFiles,array('.','..')); 

// Convert to lower case so we are not case-sensitive
 for ($i = 0; isset($excludedFiles[$i]); $i++) $excludedFiles[$i] =         
strtolower(ltrim($excludedFiles[$i],'.'));
 for ($i = 0; isset($excludedExtensions[$i]); $i++) $excludedExtensions[$i] =     

strtolower($excludedExtensions[$i]);

// Loop through directory
$count = 0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
  $extn = explode('.',$file);
  $extn = array_pop($extn);
  // Only echo links for files that don't match our rules
  if (!in_array(strtolower($file),$excludedFiles) &amp;&amp;    

!in_array(strtolower($extn),$excludedExtensions)) {
    $count++;
    print("&lt;a href=\"".$file."\"&gt;".$file."&lt;/a&gt;&lt;br /&gt;\n");
  }
}
echo '&lt;br /&gt;&lt;br /&gt;&lt;a href=".."&gt;Return&lt;/a&gt;';
closedir($handle);
}

?&gt;
</code></pre>
