PHP list all files


 

PHP list all files

In this part of the tutorial we will learn how to list all files of the given directory.We will use readdir() function to do it. And we will also see the example related to the readdir() function

In this part of the tutorial we will learn how to list all files of the given directory.We will use readdir() function to do it. And we will also see the example related to the readdir() function

  • All files, directories of the given directory can be listed.
  • function readdir() takes input as the directory handle.
  • Then readdir() returns the name of all the files and directories.


PHP List All Files Example

<?php
    $file
=opendir("c:/jboss-4.2.2.GA");
    while
($dir1=readdir($file))
      {
    echo $dir1."<br>";
       }
?>

Output:


..
bin
client
copyright.txt
docs
jar-versions.xml
JBossORG-EULA.txt
lgpl.html
lib
readme.html
server

Ads