/* purpose: read files in a directory */
//Directory to be read
$folder="H:/temp";
//Open directory
$fp=opendir($folder);
//Read table of contents
while(false!=$file=readdir($fp))
{
//List all files and remove '.' and '..'
if($file!='.' &&$file!='..')
{
//$file="$folder/$file";
$file="$file";
//Assign value to array
$arr_file[]=$file;
}
}
//Output results
if(is_array($arr_file))
{
while(list($key,$value)=each($arr_file))
{
echo "$key=>$value
";
}
}
//Close directory
closedir($fp);
?>
-----------------------
Read files in a directory 2
/* purpose: read files in a certain directory 2*/
function listFiles($dir)
{
//Open directory
$handle=opendir($dir);
//Read table of contents
while(false!=($file=readdir($handle)))
{
//List all files and remove '.' and '..'
if($file!='.'&&$file!='..')
{
//Whether the obtained file name is a directory
if(is_dir("$dir/$file"))
{
//List files in the directory
listFiles("$dir/$file");
}
else