If you do a print_r() or var_dump() of your array, you will see it only has two elements, because you use the same set of keys for both pairs of values, so the second pair overwrite the first pair. You either want to do something like Halojoy's second example, or else make the key the student's name (if it is a unique identifier):
$studentGrades = array(
'Simon' => 'A*',
'John' => 'B'
);
foreach $studentGrades as $student => $grade)
{
echo "<p>$student has a grade of $grade.</p>\n";
}
Or, for more flexibility with the ability to add more data elements per student:
$studentData = array(
'John' => array(
'semester_1_grade' => 'A-',
'semester_2_grade' => 'A+',
'attendance' => '99%'
),
'Simon' => array(
'semester_1_grade' => 'B',
'semester_2_grade' => 'A-',
'attendance' => '95%'
)
);
foreach($studentData as $student => $data)
{
echo "$student had grades of " . $data['semester_1_grade'] .
" and " . $data['semester_2_grade'] .
" with an attendance record of " . $data['attendance'] . "</p>\n";
}