Nice work mate and the code is alot tidier but the 2 week timetable wont work because of this bit:
What happens is that it only prints 2 tables with 1 filled and 1 blank i.e. week 1 table is filled and week 2 table is blank. The week 1 table is wrong because the above code will override week 2 timetable with week1. For example a student has maths in '1Mon 1' (week 1 monday period 1) and English in '2Mon 1' (week 2 monday period 1) so if you take the period out (ie 1Mon and 2Mon) and apply the array above both of em will end up with a value of 1. I should have mentioned that the kids have different timetables for each week.
$days = array('Mon' => 1, 'Tue' => 2, 'Wed' => 3, 'Thu' => 4, 'Fri' => 5,
'1Mon' => 1, '1Tue' => 2, '1Wed' => 3, '1Thu' => 4, '1Fri' => 5,
'Mon1' => 1, 'Tue1' => 2, 'Wed1' => 3, 'Thu1' => 4, 'Fri1' => 5,
'2Mon' => 1, '2Tue' => 2, '2Wed' => 3, '2Thu' => 4, '2Fri' => 5,
'Mon2' => 1, 'Tue2' => 2, 'Wed2' => 3, 'Thu2' => 4, 'Fri2' => 5);
I havent really looked it too closely just yet as im working on something else but when i get a chance i'll try and bash it to work.