PHP list contents of directory Posted on: November 2, 2009 at 12:00 AM
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>";
}
?>