Hi i am working on a docker microservices grade checker application. I am getting user input from an HttpRequest. I am lacking some basic knowledge on arrays and how to work with them in php, its a weak point for me. I currently have the below code.
<?php
function getIndividualClassification($input_text)
{
$grades = null;
$lines = explode('newline', $input_text);
foreach ($lines as $line){
if ($line >= 70 && $line <= 100){
$grades = 'Distinction';
}elseif ($line >= 60 && $line <= 69){
$grades = 'Commendation';
}elseif ( $line >= 50 && $line <= 59){
$grades = 'Pass';
}elseif ($line >= 40 && $line <= 49){
$grades = 'Marginal Fail';
}elseif ($line >= 30 && $line <= 39){
$grades = 'Fail';
}elseif ($line >= 0 && $line <= 29){
$grades = 'Low Fail';
}else{
$grades = 'Error - Check input';
}
return $grades;
}
what i am trying to do is take the input which will be any number of modules and marks in the form (module1,60) and classify each one into the above grade bands.
Input is like:
module1,60newlinemodule2,80
so i will have an output like
module1 = Pass
module2 = fail
Any help or pointers is very much apricated :)