How would I take the following array and add up and average each student, then print them out after using asort(). (This is NOT a HW assignment, I am just having a lot of trouble understanding 2d arrays and how they work so I thought I would set up an example.
$Student = array ( array (92,100,91),
array(96,82,77),
array(60,80,70),
array(90,90,90) );
help with two dimensional array
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: help with two dimensional array
foreach to loop through the outer array, then deal with the inner arrays:
Code: Select all
foreach($students as $student){
echo array_sum($student)/count($student);
}