I'm having some trouble with this function in PHP. I have a changing amount of posted items on this page, and I'm returning the variable in the array with this function:
function grade($a) {
if ($a == 1) {
return $_POST['1'];
}
if ($a == 2) {
return $_POST['2'];
}
if ($a == 3) {
return $_POST['3'];
}
if ($a == 4) {
return $_POST['4'];
}
if ($a == 5) {
return $_POST['5'];
}
if ($a == 6) {
return $_POST['6'];
}
//... you get the idea
}
This is probably not the right way. How can I make this function shorter so that I don't have to make the if-statement for every possible array variable?
Thanks for you help!