Я делаю расписание для школы. Я уже выбрал данные из БД, но все данные представлены в начале, в 7.10 (рис. 1). Но некоторые уроки начинаются в 7,10, другие начинаются в 8 утра. Я понятия не имею, как эти данные сдвигаются, если уроки начинаются, например, в 8 утра. Я нашел php-функцию array_unshift, но на самом деле мне нужно добавить некоторые элементы в начале?
Мне нужно сдвинуть данные, если start_time урока не равно start_time (верхняя строка на рисунке)
фото 1
Я сделал это с циклом foreach и массив, который представляет расписание:
$timetable[$day]['lessons'][$z]['dividedlessons'][$q]['start_time']
$z
индекс для индивидуального занятия — на рис. 0,1,2,3,4;
разделенные уроки означают, что у учеников есть 2 разных урока в течение одного урока;
а также $q
индекс для разделенного урока; список часов — 07:10, 08:00, 08: 50 и т. д.
Array ( [start_time] => 0000-00-00 08:00:00 [end_time] => 0000-00-00 08:45:00 [group] => [name] => BIO [room] => CP [lector] => Reh )
Array ( [start_time] => 0000-00-00 08:50:00 [end_time] => 0000-00-00 09:35:00 [group] => [name] => MAT [room] => CP [lector] => Ĺ af )
Array ( [start_time] => 0000-00-00 09:55:00 [end_time] => 0000-00-00 10:40:00 [group] => [name] => SLJ [room] => CP [lector] => Bal )
Array ( [start_time] => 0000-00-00 10:45:00 [end_time] => 0000-00-00 11:30:00 [group] => [name] => ANJ [room] => CP [lector] => Šán
Array ( [start_time] => 0000-00-00 11:40:00 [end_time] => 0000-00-00 12:25:00 [group] => [name] => FYZ [room] => BF [lector] => Kis )
Array ( [start_time] => 0000-00-00 12:35:00 [end_time] => 0000-00-00 13:20:00 [group] => 1.sk [name] => INF [room] => AI [lector] =>
Haj )
Array ( [start_time] => 0000-00-00 12:35:00 [end_time] => 0000-00-00 13:20:00 [group] => ETV [name] => ETV [room] => CP [lector] => Cse )
Array ( [start_time] => 0000-00-00 13:30:00 [end_time] => 0000-00-00 14:15:00 [group] => 2.sk. [name] => INF [room] => AI [lector] => Haj )
Array ( [start_time] => 0000-00-00 08:00:00 [end_time] => 0000-00-00 08:45:00 [group] => [name] => ANJ [room] => CP [lector] => Šán )
Array ( [start_time] => 0000-00-00 08:50:00 [end_time] => 0000-00-00 09:35:00 [group] => [name] => MAT [room] => CP [lector] => Ĺ af )
Array ( [start_time] => 0000-00-00 09:55:00 [end_time] => 0000-00-00 10:40:00 [group] => [name] => DEJ [room] => CP [lector] => Str )
Array ( [start_time] => 0000-00-00 10:45:00 [end_time] => 0000-00-00 11:30:00 [group] => [name] => GEO [room] => CP [lector] => StK )
Array ( [start_time] => 0000-00-00 11:40:00 [end_time] => 0000-00-00 12:25:00 [group] => [name] => TSV [room] => T1 [lector] => Cse )
Array ( [start_time] => 0000-00-00 12:35:00 [end_time] => 0000-00-00 13:20:00 [group] => [name] => SLJ [room] => CP [lector] => Bal )
Array ( [start_time] => 0000-00-00 08:00:00 [end_time] => 0000-00-00 08:45:00 [group] => [name] => SLJ [room] => CP [lector] => Bal )
Array ( [start_time] => 0000-00-00 08:50:00 [end_time] => 0000-00-00 09:35:00 [group] => [name] => MAT [room] => CP [lector] => Ĺ af )
Array ( [start_time] => 0000-00-00 09:55:00 [end_time] => 0000-00-00 10:40:00 [group] => [name] => ANJ [room] => CP [lector] => Šán )
Array ( [start_time] => 0000-00-00 10:45:00 [end_time] => 0000-00-00 11:30:00 [group] => [name] => OBN [room] => CP [lector] => Kis )
Array ( [start_time] => 0000-00-00 11:40:00 [end_time] => 0000-00-00 12:25:00 [group] => [name] => VYV [room] => CP [lector] => Reh )
Array ( [start_time] => 0000-00-00 12:35:00 [end_time] => 0000-00-00 13:20:00 [group] => [name] => NEJ [room] => CP [lector] => Til )
Array ( [start_time] => 0000-00-00 08:00:00 [end_time] => 0000-00-00 08:45:00 [group] => [name] => ANJ [room] => CP [lector] => Šán )
Array ( [start_time] => 0000-00-00 08:50:00 [end_time] => 0000-00-00 09:35:00 [group] => [name] => TSV [room] => T1 [lector] => Cse )
Array ( [start_time] => 0000-00-00 09:55:00 [end_time] => 0000-00-00 10:40:00 [group] => [name] => MAT [room] => CP [lector] => Ĺ af )
Array ( [start_time] => 0000-00-00 10:45:00 [end_time] => 0000-00-00 11:30:00 [group] => [name] => SLJ [room] => CP [lector] => Bal )
Array ( [start_time] => 0000-00-00 11:40:00 [end_time] => 0000-00-00 12:25:00 [group] => [name] => CHE [room] => CP [lector] => Ĺ af )
Array ( [start_time] => 0000-00-00 12:35:00 [end_time] => 0000-00-00 13:20:00 [group] => NAV [name] => NAV [room] => [lector] => Kub )
Array ( [start_time] => 0000-00-00 08:00:00 [end_time] => 0000-00-00 08:45:00 [group] => [name] => MAT [room] => CP [lector] => Ĺ af )
Array ( [start_time] => 0000-00-00 08:50:00 [end_time] => 0000-00-00 09:35:00 [group] => [name] => SLJ [room] => CP [lector] => Bal )
Array ( [start_time] => 0000-00-00 09:55:00 [end_time] => 0000-00-00 10:40:00 [group] => [name] => TSV [room] => T1 [lector] => Cse )
Array ( [start_time] => 0000-00-00 10:45:00 [end_time] => 0000-00-00 11:30:00 [group] => [name] => BIO [room] => CP [lector] => Reh )
Array ( [start_time] => 0000-00-00 11:40:00 [end_time] => 0000-00-00 12:25:00 [group] => [name] => CHE [room] => CP [lector] => Til )
Array ( [start_time] => 0000-00-00 12:35:00 [end_time] => 0000-00-00 13:20:00 [group] => [name] => HUV [room] => CP [lector] => Bal )
«скратка» — это сокращение от дней; «ходины» — это уроки, а «деленеходины» — безраздельные.
Я попытался объяснить это ясно, я надеюсь, что вы поймете 🙂 Спасибо!
Задача ещё не решена.
Других решений пока нет …