
Murshed A. answered 11/14/15
Tutor
5
(11)
Experienced Engineering tutor who gets results!
So the first step is to set up an array. As the first sentence of your problem mentions, you can define an array in PHP by simply using the array() function and providing key-value pairs. In this case, since your index (key) is the roll number and the value is the students' names, you can do the following:
$student = array(
1 => 'Ahmed Ali',
2 => 'Ikram'
);
I've only put two students here, as you should be able to put the rest on your own.
To print the array, you can use a foreach loop. This will loop through each element and you can print one at a time.
foreach ($student as $key=>$value) {
echo 'Student ' . $key . ': ' . $value . "\n";
}
You can also use the built-in print_r() function and pass in the array you need.