I noticed there are squares after the country name which shouldn't be there (shown in the attachment picture): If you have an understanding of PHP it was probably because of this: [2] => Array ( [0] => Afghanistan [1] => Albania [2] => Algeria [3] => American Samoa Code (markup): There is the space between the countries. That code derived from: $string = '<SELECT NAME="country" style="border: 1px solid #990000; font-family:Arial,Helvetica,Univers,Zurich BT; "> <OPTION SELECTED VALUE="US" >United States <option value="AF">Afghanistan <option value="AL">Albania <option value="DZ">Algeria ... </SELECT>'; preg_match_all("#<option value=\"([^\"]+)\">([^<]+)#", $string, $foo); print_r($foo); //value in foo[1], contents and foo[2] PHP:
Those squares are non-printable characters like tabs or line feeds. I think the problem is with the select statement. The option tags aren't closed. Try this: $string = '<SELECT NAME="country" style="border: 1px solid #990000; font-family:Arial,Helvetica,Univers,Zurich BT; "> <OPTION SELECTED VALUE="US" >United States</option> <option value="AF">Afghanistan</option> <option value="AL">Albania</option> <option value="DZ">Algeria</option> ... </SELECT>'; To remove the existing squares try this: UPDATE Table SET Column = REPLACE(REPLACE(Column, CHAR(13), ''), CHAR(10), '')