Home Tutorial Php List PHP listing files in folder

 
 

PHP listing files in folder
Posted on: November 2, 2009 at 12:00 AM
In this tutorial we will learn how to list all files present in the folder. In the example we will show it with the use of readdir() function

  • All files, folder   of the given folder can be listed.
  • Function readdir() takes input as the folder handle.
  • Then readdir() returns the name of all the files and folders.


Example of PHP Listing Files in Folder
<?php
     $file
=opendir("c:\apache-maven-2.1.0-bin");
     do
    
{
     echo
$a."<br>";
      }
     while
($a=readdir($file));
?>


Output
.
..
bin
boot
conf
lib
LICENSE.txt
NOTICE.txt
README.txt

Related Tags for PHP listing files in folder:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.