为什么$ k每次都通过循环重置为零?
$fruit = array (“orange”, “apple”, “grape”);
$testvar = “no”;
while ($testvar != “yes”) {
$k = 0;
if ($fruit[$k] == “apple”) {
$testvar = “yes”;
echo “apple\n”;
} else {
echo “$fruit[$k] is not an apple\n”;
}
$k++;
}
在while语句前放置'$ k' – 2014-09-25 04:26:51