file extension php list folder
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3226519/use-php-scandirdir-and-get-only-images">use php scandir($dir) and get only images!</a>  </p>
</blockquote>



<p>I've got the following code to pull a list of files from a folder into a menu.</p>

<p>I want to store other files in this folder though so how do I say that I only want to load files with a certain extension?  <code>PDF</code> is actually the files I want.</p>

<pre><code>&lt;?php
    $dir = 'documents'; 
    $files = scandir($dir); 
    foreach($files as $ind_file)
    if ($ind_file != '.' &amp;&amp; $ind_file != '..') { 
?&gt;
    &lt;li&gt;&lt;a href="&lt;?php echo $dir."/".$ind_file;?&gt;"&gt;&lt;?php echo $ind_file;?&gt;&lt;/a&gt;&lt;/li&gt;
&lt;?php 
    }
?&gt;
</code></pre>
