title: Using PHP and RegEx to fetch all option values from a site's source code
body: <p>I'm learning RegEx and site crawling, and have the following question which, if answered, should speed my learning process up significantly.</p>
  
  <p>I have fetched the form element from a web site in htmlencoded format. That is to say, I have the $content string with all the tags intact, like so:</p>
  
  <pre><code>$content = "&lt;form name="sth" action=""&gt;
  &lt;select name="city"&gt;
  &lt;option value="one"&gt;One town&lt;/option&gt;
  &lt;option value="two"&gt;Another town&lt;/option&gt;
  &lt;option value="three"&gt;Yet Another town&lt;/option&gt;
  ...
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I would like to fetch all the options on the site, in this manner:</p>
  
  <pre><code>array("One Town" =&gt; "one", "Another Town" =&gt; "two", "Yet Another Town" =&gt; "three" ...);
  </code></pre>
  
  <p>Now, I know this can easily be done by manipulating the string, slicing it an dicing it, searching for substrings within each string, and so on, until I have everything I need. But I'm certain there must be a simpler way of doing it with regex, which should fetch all the results from a given string instantly. Can anyone help me find a shortcut for this? I have searched the web's finest regex sites, but to no avail.</p>
  
  <p>Many thanks</p>