是否可能,并且通过执行以下操作:
假设您在for循环中有一个if语句。每当该if语句的第一个条件为true时,就将相同的单词添加到数组中。
类似这样的东西:
for($i=1; $i<=$5; $i++){
if($name[$i-1] == "voornaam $i"){
///adds the word 'correct' to the array $successlist /// ;
} else{
///adds the word 'incorrect' to the array $successlist /// ;
} }
如果一切正常,则数组应如下所示:
$成功列表(正确,正确,正确,正确,正确等)
提前感谢。
if(condition){
$successList[] = 'correct';
}else{
$successList[] = 'incorrect';
}
// Not $5, but `5` and start from 0:
for ($i=0; $i<5; $i++) {
if($name[$i] == "voornaam $i"){
$successlist[] = 'correct';
} else{
$successlist[] = 'incorrect';
}
}