Alright I have the array $selectedcounties and I have the array $countryrow which is an array based off MySQL results. I want to compare each $countyrow array value to all of the $selectedcounties array values to see if they have a match. If they do the $selected variable is set when i'm building a dropdown list.

The code only works part way. Any better way to do this?

PHP Code:
$selectedcounties explode(",",$notify['counties']);

while (
$countyrow mysql_fetch_array($county))
{    
    
$selected "";
    
    foreach(
$selectedcounties as $value)
    {
        if(
$value == $countyrow['county'])
        {
            
$selected " selected";
        }
    }
    
    
$countydata .= '<option value="'.$countyrow['county'].'"'.$selected.'>'.ucwords(strtolower($countyrow['county'])).'</option>';