How can I get PHP to list the directories inside of a directory in a select dropdown input?

How can we get PHP to list the directories inside of the office in the name dropdown input?

Let’s contend which inside of office test, there have been 5 files as well as 2 directories.

I wish to arrangement usually the directories in the dropdown submit box.

How could we do this?

One thought on “How can I get PHP to list the directories inside of a directory in a select dropdown input?

  1. Not too familiar with glob but if you wanna use readdir…

    <select>
    <?php
      if ($handle = opendir(‘.’)) {
            while (false !== ($file = readdir($handle))) {
            if (is_dir($file)) {
                echo "<option value=’$file’>$file</option>";
            }
        }
        closedir($handle);
    }
    ?>
    </select>