读入特定目录中的所有文件会在html列表中显示文件名

Reading all the files from a particular directory and displays the files names/Links in a html list. (file ext: .pdf) I'm looking for output something like:

  • filename 1
  • filename 2
  • filename 3

My code:

<ul> 
    <?php 
      $dir = '/my_directory_location'; 
      $files = scandir($dir); 
      foreach ($files as $ind_file) { 
      ?> <li> <a href="<?php echo $dir."/".$ind_file;?>"><?php echo $ind_file;?></li> 
      <?php } ?> 
</ul>

Thanks in Advance

You probably need the glob() in PHP

<?php
foreach (glob("*.pdf") as $filename) {
    echo "$filename<br>";
}

OUTPUT :

resume1.pdf
resume4.pdf
resume5.pdf

try with this

$ARR_FILES = glob($PATH_TO_YOUR_DIRECTORY."/*.pdf");
foreach($ARR_FILES as $filename)
{
  echo $filename."<br/>";
}