PHP Variables in Functions -


i trying make grading scales grouping of variables. i'm running in few problems , brain dead @ moment. possibly give me on how accomplish this? appreciated!

function ovr_grade($talent, $physical, $entertainment, $reputation, $overness) { if ($talent || $physical || $entertainment || $reputation || $overness >= 90) { return "grade: a"; } elseif ($talent || $physical || $entertainment || $reputation || $overness >= 80) { return "grade: b"; } elseif ($talent || $physical || $entertainment || $reputation || $overness >= 70) { return "grade: c"; } elseif ($talent || $physical || $entertainment || $reputation || $overness >= 60) { return "grade: d"; } elseif ($talent || $physical || $entertainment || $reputation || $overness >= 50) { return "grade: e"; } elseif ($talent || $physical || $entertainment || $reputation || $overness <= 49) { return "grade: f"; } else { return "n/a"; } }  echo ovr_grade(); 

i aaprreciate "james anderson" answer +1 him,but max() calculation can reduced

$grades=  max($talent,$physical,$entertainment,$reputation);  if($grades>90) { return "grade: a"; }  elseif ($grades>80) { return "grade: b"; }  . . . . . . else  { return "n/a"; } 

update:

unfortunately cant deep in "comment" anyway , think need general function returns grade each factor (eg:physical,entertainment ... )

function  getgrades($factor) {  $grades= $factor;  if($grades>90) { return "grade: a"; }  elseif ($grades>80) { return "grade: b"; }  . . . . . . else  { return "n/a"; } } 

and make call grade each

echo "talent : " . getgrades($talent); echo "physical : " . getgrades($physical); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -