lottos wrote:the table row is populated with a space between each state:
You can stop right there. Whatever there is to follow there's not a lot of point in trying to knock it into shape before getting the database properly sorted out and normalised so that each state gets its own row.
Now, assuming you've got the selected state abbreviations from the table in an array $stateArr:
foreach($states as $ab=>$name)
{
if(in_array($ab, $stateArr))
{
//...etc.
}
}