Populate HTML dropdown from text file
<p>I have a dropdown menu with hard-coded values:</p>

<pre><code>&lt;select name="value" id="value"&gt;
  &lt;option value="A"&gt;A&lt;/option&gt;
  &lt;option value="B"&gt;B&lt;/option&gt;
  &lt;option value="C"&gt;C&lt;/option&gt;
  &lt;option value="D"&gt;D&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>I would like to load a text file to populate the values. The text file will have each value on a new line.</p>

<p>values.txt</p>

<pre><code>A
B
C
D
</code></pre>

<p>I've tried this:</p>

<pre><code>&lt;select&gt;
    &lt;?php
    if ($file = @fopen('values.txt', 'r')) {
        while(($line = fgets($file)) !== false) {
            echo "&lt;option&gt;{$line}&lt;/option&gt;";
        }
        fclose($file);
    }
?&gt;
&lt;/select&gt;
</code></pre>

<p>But there are no choices on the dropdown when I do this.</p>

<p>Any help would be appreciated. Thanks!</p>