How to validate an array in a PHP form?
<p>I'm fairly new to php and was wondering how do I validate the array for the states and where do I place the php code at? I already did the address part but I'm stuck at the states part.</p>

<p>Here is the validation code.</p>

<pre><code>if (isset($_POST['contact_info_submitted'])) { // Handle the form.

    $address = mysqli_real_escape_string(htmlentities($_POST['address']));

}
</code></pre>

<p>Here is the form code.</p>

<pre><code>&lt;li&gt;&lt;label for="address-1"&gt;Address 1: &lt;/label&gt;&lt;input type="text" name="address-1" id="address-1" size="25" class="input-size" value="&lt;?php if (isset($_POST['address'])) echo $_POST['address']; ?&gt;" /&gt;&lt;/li&gt;

&lt;li&gt;&lt;label for="state-province"&gt;State/Province: &lt;/label&gt;
&lt;?php
echo '&lt;select name="state-province" id="state-province"&gt;' . "\n";
    foreach($state_options as $option) {
        if ($option == $state) {
            echo '&lt;option value="' . $option . '" selected="selected"&gt;' . $option . '&lt;/option&gt;' . "\n";
            } else {
              echo '&lt;option value="'. $option . '"&gt;' . $option . '&lt;/option&gt;'."\n";
            }
        }
            echo '&lt;/select&gt;';

?&gt;
&lt;/li&gt;
&lt;li&gt;&lt;input type="submit" name="submit" value="Save Changes" class="save-button" /&gt;
    &lt;input type="hidden" name="contact_info_submitted" value="true" /&gt;
</code></pre>
