Re: * populate menu from directory *
| From: | Matt Matijevich | Date: | Mon, 16 Feb 2004 19:42:22 +0000 |
| Subject: | Re: * populate menu from directory * | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-177852@lists.php.net to get a copy of this message | ||
<snip>
I want to be able to simply FTP a new movie
onto the server, and then have the menu update itself. possible? I
would also be looking to do something similar with JPGS.
</snip>
take a look at
http://www.php.net/readdir
http://www.php.net/opendir
here is some code to help start you
echo '<select name="movies">';
if ($handle = opendir('moviesdirectory')) {
while (false !== ($file = readdir($handle))) {
if (preg_match("/\.mov$/i", $file)) { //the regular expression
might have to be modified to allow for the file extensions you want to
use
echo "<option>$file</option>\n";
}
}
closedir($handle);
}
echo '</select>';