I have a string that I grab from my DB which has town and zipcode information in it. I want to extract the zipcodes (always 5 digits) from it and build a select statement from it (using PHP) as follows:
$townZip = 'Boston(02108, 02112, 02116), Chelsea (02150), Revere (02151)';
<select>
<option value="">Please Select</option>
<option value="02108">02108</option>
<option value="02112">02112</option>
<option value="02116">02116</option>
<option value="02150">02150</option>
<option value="02151">02151</option>
</select>
Please note that the string can have varying number of towns, zipcodes so that solution has to be flexible enough to accomodate this.