如何在PHP中修复条件错误中的赋值?

I have this code:

while (list ($key, $val) = each ($ethnicity)) {
    if ($val == '')
        $ethnicity = '';
    break;
}

and I get an error saying: Assignment in condition, Change to ==

But I can't change it to == or it's not working.

Anyone care to explain to me why this is happening?

edit.

the error is for the first line.

also i get the same error here:

             while (($row = mysql_fetch_row ($result)))
            {   
             $sms_providerchecked0= $row[3];
             $to_return_email12 = $cell."@$sms0";
            }

in the first line

while ( false!=(list($key, $val)=each($ethnicity)) ) {

I don't have zend studio so this might or might not do the trick...

Have you tried putting an extra set or parentheses around the condition?

IE:

while ((list ($key, $val) = each ($ethnicity))) 
{
    if ($val == '')
    $ethnicity = '';
    break;
}

Also, what IDE are you using, as this very likely could just be a problem with your IDE being overzealous about preventing unintentional assignments in condition.

EDIT:

As you are using zend, and your code is perfectly valid, it looks like if you want to stop seeing the warning so that you can write your code the way that you want to(this is an erroneous warning), you can disable that warning in Window | Preferences, PHP | Semantic Analysis.

$row = mysql_fetch_row($result);
while ($row) {   
    $sms_providerchecked0= $row[3];
    $to_return_email12 = $cell."@$sms0";
    $row = mysql_fetch_row($result);
}