Directory to array to select box...
| From: | Jas | Date: | Fri, 05 Apr 2002 15:32:35 +0000 |
| Subject: | Directory to array to select box... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-91722@lists.php.net to get a copy of this message | ||
Ok here is my problem, for one I am new to php and would like a new pair of
eyes for this piece of code, and second what I would like to accomplish is
putting the contents of a directory into an array and then pulling the
contents of that array into a select box for further processing... If
someone could give me some more information on GetDirArray() or a different
way to accomplish this problem that would be great... this is where I am
thus far.
<?php
$i=0; // counter
$files = array(); // array to store directory content
// open directory
$dir = opendir("/home/web/b/bignickel.net/htdocs/");
// loop through directory and put filenames into an array
while ($file = readdir($dir)) {
$files[$i] = $file;
$i++;
}
// pull $file (directory array into select box)
$file_count .="<OPTION VALUE=\"$file\">$file</OPTION>";
$form = "<p><FORM METHOD=\"post\" ACTION=\"blank.php3\">
<SELECT NAME=\"files\">$file_count</SELECT>
<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"select\">
</FORM></p>";
// close directory
closedir($dir);
?>
Then of course I just use an echo to display the select box but so far I
have not been able to have it actually work so any help would be great..
Thanks in advance,
jas