title: PHP - Get other extensions of file
body: <p>I'm new to PHP and need help.</p>
  
  <p>I have a folder with files like:</p>
  
  <pre><code>D:\fold\A.pdf
  D:\fold\A.doc
  D:\fold\A.xls
  D:\fold\A.txt
  </code></pre>
  
  <p>for some work I'm using the <code>A.txt</code> file, now I need to echo other files as well from the same folder path.</p>
  
  <p>Like if <code>A.txt</code> is searched echo </p>
  
  <pre><code>A.pdf
  A.xls
  A.doc
  </code></pre>
  
  <p>I tried something:</p>
  
  <pre><code>$filename = basename($value, ".txt"); //$value has the whole path and the extension is .txt
  echo $path = pathinfo($value, PATHINFO_DIRNAME) ."\\". $filename;// prints the path &amp; base name.
  </code></pre>
  
  <p>But how to print the extensions other than '.txt'?</p>
  
  <hr>
  
  <p>Thanks for the suggestions and I tried something like this, </p>
  
  <pre><code>$value = "D:\\Fold\\A.txt";
  $filename = basename($value, ".txt"); 
  $path = pathinfo($value, PATHINFO_DIRNAME) ."\\". $filename; 
  foreach (glob($path."*") as $filenames)  
   {   
    if (!strpos($filenames, ".txt"))
    echo $filenames; 
   }
  </code></pre>
  
  <p>This the right answer.</p>