I'm trying to learn PHP, it's a simple program that has 3 numeric marks and for example if a note is less than 6 i want to echo the amount of failed marks. But i'm not getting results in any function i made using for loops and ifs statement, for example arrainging an array from best marks to lower marks. Here is the code for the amount of low marks function:
function calculateLowMarks($marksArray){
$lowCounter = 0;
for($i = 0; i < var_dump(count($marksArray)); $i++){
if($marksArray[$i] < 6){
$lowCounter++;
}
}
if($lowCounter == 0){
echo 'There isnt any low mark ';
}
if($lowCounter > 0){
echo 'There is ' . $lowCounter . 'failed marks';
}
}
I'm also getting a warning in every for loop statement: Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP)
Aucun commentaire:
Enregistrer un commentaire