Undefined index in $_POST with multiple select
<p>I have a form that contains a multiple <code>&lt;select&gt;</code> element. I want to be able to have PHP retrieve a list of all the options in the <code>&lt;select&gt;</code>.</p>

<p>The user can add items to the <code>&lt;select&gt;</code> by clicking various things on the page. This adds items to the <code>&lt;select&gt;</code> dynamically via JavaScript.</p>

<p>Skeleton of my HTML form:</p>

<pre><code>&lt;form action="submit.php" method="post"&gt;
    &lt;select id='list' name='items[]' multiple='multiple'&gt;
    &lt;/select&gt;

    &lt;input type='submit' value='Save' /&gt;
&lt;/form&gt;
</code></pre>

<p>And my <code>submit.php</code>:</p>

<pre><code>&lt;?php
    $list = $_POST["items"]; // returns 'undefined index' error
    for($i = 0; $i &lt; count($list); $i++) {
        echo $list[$i] . "&lt;br /&gt;";
    }
?&gt;
</code></pre>

<p>I have been looking around a lot on this issue and can't find anything that works. I have tried changing everything with POST to GET and that doesn't change anything.</p>

<p>When I do <code>var_dump($_POST)</code>, I get:</p>

<pre><code>array(0) { }
</code></pre>

<p>I am using an XAMPP server on my local machine, not sure if that is contributing to the issue.</p>

<p>Thanks for any help.</p>