note 29128 rejected from function.opendir by didou
| From: | didou@php.net | Date: | Fri, 03 Oct 2003 10:24:08 +0000 |
| Subject: | note 29128 rejected from function.opendir by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57675@lists.php.net to get a copy of this message | ||
Note Submitter: tvorobjo@colby.edu
----
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???