function addSlot($timetableID, $slot, $game, $numberOfSlots) { $thisTimetable = Timetable::find_by_timetableid($timetableID); $contents = unserialize($thisTimetable->contents); $day = substr($slot, 0, 3); $time = intval(substr($slot, 4, 2)); //counter for extra slots //Add to the array for how ever many slots there it for ($x = 1; $x <= intval($numberOfSlots); $x++) { $contents['timetable'][$day][$time] = $game; //Increment counters $time++; } $contents = serialize($contents); $thisTimetable->contents = $contents; $thisTimetable->save(); }