samedi 1 février 2020

how does one add words to an array through if statements in a for-loop?

Is the following possible, and if so by doing what:

Suppose you have an if-statement within a for-loop. Each time the first condition of that if-statement is true, the same word is added to an array.

Something like this:

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 things go right, the array should look something like this:

$successlist (correct, correct, correct, correct, correct) etc.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire