note 29128 modified in function.opendir by goba

From: Date: Sat, 23 Aug 2003 17:39:31 +0000
Subject: note 29128 modified in function.opendir by goba
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54968@lists.php.net to get a copy of this message
Here is a way I use to get all the filenames into an array: <?php $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"; ?> ----------------------------------------------- anyone knows how to search throught subdirectories of $mydir??? --was-- Here is a way I use to get all the filenames into an array: $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"; ----------------------------------------------- anyone knows how to search throught subdirectories of $mydir??? http://www.php.net/manual/en/function.opendir.php

« previous php.notes (#54968) next »