Share on Google+Share on Google+

PHP list all files

Advertisement
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

Advertisements

Posted on: October 31, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.