I'm learning RegEx and site crawling, and have the following question which, if answered, should speed my learning process up significantly.
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:
$content = "<form name="sth" action="">
<select name="city">
<option value="one">One town</option>
<option value="two">Another town</option>
<option value="three">Yet Another town</option>
...
</select>
</form>
I would like to fetch all the options on the site, in this manner:
array("One Town" => "one", "Another Town" => "two", "Yet Another Town" => "three" ...);
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.
Many thanks