This one is a little tough because I do not know if $actual_answer is a number or a string. If it's a string I would probably use the strcmp(str1, str2) command instead.
In reality there is nothing wrong with the code that was submitted. I guess we would need to see the rest of the code because the function does work. I added a print command to see what was being displayed and in this example the first output is 3 and the second is 4.
Code:
$actual_answer = "Don't know";
$answers[0] = "Yes";
$answers[1] = "No";
$answers[2] = "Don't know";
$results[0] = "2";
$results[1] = "7";
$results[2] = "3";
$set_num = 0;
while ( $answers[$set_num] != "" )
{
if ( $answers[$set_num] == $actual_answer )
{
print $results[$set_num];
print "<BR>";
$results[$set_num]++;
print $results[$set_num];
print "<BR>";
}
$set_num++;
}
unset($set_num);