Home Tutorial Php List PHP list all files in directory

 
 

Share on Google+Share on Google+
PHP list all files in directory
Posted on: October 30, 2009 at 12:00 AM
Advertisement
In this tutorial we will learn to list all the files and directories in the given directory name.

  • Using the readdir() and opendir() function all files of the directory can be listed.
  • readdir() function uses the file handler of the readdir() function.
  • It then returns the filename of the directory.


Example

<?php
    $file
=opendir("c:/apache-tomcat-6.0.16");
     while
($a=readdir($file))
       {
        echo
$a."<br>";
       }
?>

Output
.
..
bin
conf
lib
LICENSE
logs
NOTICE
RELEASE-NOTES
RUNNING.txt
spring1.war
temp
webapps
work

Advertisement

Related Tags for PHP list all files in directory:


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.

Posted on: October 30, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com