Home Tutorial Php List PHP list contents of directory

 
 

Share on Google+Share on Google+
PHP list contents of directory
Posted on: November 2, 2009 at 12:00 AM
Advertisement
This section of the PHP tutorial describes how to display the contents of the given directory. In the example we the use of readir() and opendir()to display the contents of the directory.

  • Contents of a directory or a folder can be displayed one by one.
  • readdir() function returns the directory as well as file name.
  • readdir() takes input as opendir() handle.On success returns the String


Example of PHP List Constents of Directory
<?php
$file
=opendir("c:\apache-ant-1.7.1-bin");
for
(;$a=readdir($file);){
echo
$a."<br>";
}
?>

Output:

..
bin
docs
etc
fetch.xml
get-m2.xml
INSTALL
KEYS
lib
LICENSE
NOTICE
README
WHATSNEW
Advertisement

Related Tags for PHP list contents of 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: November 2, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com