title: php regex to read select form with select field
body: <p>Hi I have an issue with the regular expression based off the question below: <br>
  <strong>Question:</strong> [php-regex-to-read-select-form][1]</p>
  
  <p>The HTML code I wish for the regular expression to go through </p>
  
  <pre><code>&lt;select name="List"&gt;
      &lt;option selected="selected" value="HAR"&gt;HAR&lt;/option&gt;
      &lt;option value="HAY"&gt;HAY&lt;/option&gt;
      &lt;option value="ZZZ"&gt;ZZZ&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The php I currently have is as follows:</p>
  
  <pre><code>preg_match_all( '@(&lt;option value="([^"]+)"&gt;([^&lt;]+)&lt;\/option&gt;)@', $html, $viewstate);
  
      echo "&lt;pre&gt;";
      print_r($viewstate);
      echo "&lt;/pre&gt;";
      die();
  </code></pre>
  
  <p>The output from that is as follows:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; HAY
              [1] =&gt; ZZZ
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; HAY
              [1] =&gt; ZZZ
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; HAY
              [1] =&gt; ZZZ
          )
  
      [3] =&gt; Array
          (
              [0] =&gt; HAY
              [1] =&gt; ZZZ
          )
  
  )
  </code></pre>
  
  <p>So I am a bit confused why it creates the results muiltiple times and do now know how to get it to get the <code>&lt;option</code> tag with the selected attribute set.</p>