list files in a dictory and its subdirectories

From: Date: Tue, 04 Feb 2003 00:14:11 +0000
Subject: list files in a dictory and its subdirectories
Groups: php.general 
Request: Send a blank email to php-general+get-134199@lists.php.net to get a copy of this message
hey! this is the code I'm using to get into array all filenames in a directory: ---------------------------------------------------------------- $mydir = mydir //the directory name $output_file = fopen($data_file, "w"); $begin = "<? \$files_name = array("; fwrite($output_file, $begin); $output_file = fopen($data_file, "w"); if ($handle = opendir('./$mydir/')) { while (false !== ($filename = readdir($handle))) { if ($file != "." && $filename != "..") { //&& !is_dir($filename) can be added $element = "\"$filename\","; fwrite($output_file, $element); } } closedir($handle); } fwrite($output_file,"\"\");\r\n"); fwrite($output_file, "?>"); fclose($output_file); chmod($output_file, 0777); //to preview echo "the list has been succesfully created"; ---------------------------------------------------------------- now, how can I make the script to look into subdirectories of ./$mydir/ and output also those filenames into the same or another array? thank you

« previous php.general (#134199) next »