How can PHP be used to automatically display all subfolders in a directory in a dropdown menu on a webpage?
To automatically display all subfolders in a directory in a dropdown menu on a webpage using PHP, you can use the `scandir()` function to retrieve a list of all directories within the specified directory. Then, iterate through the list and generate HTML `<option>` tags for each subfolder to populate the dropdown menu.
<select>
<?php
$directory = "path/to/directory";
$subfolders = array_diff(scandir($directory), array('..', '.'));
foreach ($subfolders as $subfolder) {
if (is_dir($directory . '/' . $subfolder)) {
echo "<option value='$subfolder'>$subfolder</option>";
}
}
?>
</select>