/* Purpose: Read the file under a directory */
The directory to read
$folder = "H:/temp";
Open Directory
$FP =opendir ($folder);
Read Catalogue
while (false!= $file =readdir ($fp))
{
List all files and remove '. ' and ' ... '
if ($file! = '. ' && $file! = ' ... ')
{
$file = "$folder/$file";
$file = "$file";
assigning values to arrays
$arr _file[]= $file;
}
}
Output results
if (Is_array ($arr _file))
{
while (list ($key, $value) =each ($arr _file))
{
echo "$key and $value
";
}
}
Close Directory
Closedir ($FP);
?>
----------------------
Read a file in a directory 2
/* Purpose: Read the file under a directory two */
function Listfiles ($dir)
{
Open Directory
$handle =opendir ($dir);
Read Catalogue
while (false!= ($file =readdir ($handle)))
{
List all files and remove '. ' and ' ... '
if ($file! = '. ') && $file! = ' ... ')
{
Whether the resulting file name is a directory
if (Is_dir ("$dir/$file"))
{
List files in directory
Listfiles ("$dir/$file");
}
Else
http://www.bkjia.com/PHPjc/631972.html www.bkjia.com true http://www.bkjia.com/PHPjc/631972.html techarticle PHP/* Purpose: Read the file in a directory *///directory to read $folder =h:/temp;//Open Directory $fp =opendir ($folder);//Read directory while (false!= $file = Readdir ($FP)) {//list ...