That is a good start and gives me something to play with.
The only question now is how do I figure out what the current graduation year would be because that value won’t be input anywhere in the the database I’m working with.
I don’t understand, if you’re running this script in your program, then everytime it’s called it’s using the variable set within the function, so you should have complete control over what $currentGradYear is equal to.
Anywho, a little modification (has comments to understand):
## -- Takes the graduation year and returns what
## -- grade the student is in currently.
## -- Based on a 12 grade system.
function currentGrade($graduationDate)
{
## -- Sets current month equal to the number of the month
$currentMonth = date("n");
## -- Sets current graduation year to the current year,
## -- HOWEVER: If it is after june (6), it adds one to the year.
$currentGradYear = ($currentMonth>6) ? date("Y")+1 : date("Y");
## -- Formulates their current grade is the currentGradYear subtracted
## -- from their graduation date.
## -- Then subtracts that from 12 since there are only 12 grades
$currentGrade = $graduationDate-$currentGradYear;
$currentGrade = 12-$currentGrade;
## -- Returns their current grade concatenated with " grade."
return $currentGrade." grade.";
}