Я пытаюсь создать несколько таблиц HTML из многомерного массива. Я уже создал массив, но я не знаю, как перевести этот массив в несколько таблиц HTML.
Я хочу разделить таблицы на основе времени и имени класса, которое открывается в текущий день.
Чтобы прояснить ситуацию, вот мой код:
$title = [];
$table_rows = [];
// build table arrays
foreach ($schedule AS $row)
{
$title[] = $row->time.' - '.$row->class_name;
$table_rows[$row->time][$row->class_name][] = ['student_id' => $row->student_id, 'mentor_code' => $row->mentor_code, 'student_name' => $row->student_name];
}
// $title array (using array_unique($title) to removes duplicate values
Array
(
[0] => 07:30-08:30 - E-1
[1] => 08:30-09:30 - E-1
[2] => 10:00-11:00 - E-1
[3] => 11:00-12:00 - E-1
[12] => 07:30-08:30 - E-2
[13] => 08:30-09:30 - E-2
)
// $table_rows array
Array
(
[07:30-08:30] => Array
(
[E-1] => Array
(
[0] => Array
(
[student_id] => 1012836001
[mentor_code] => TPA-1
[student_name] => Vanessa
)
[1] => Array
(
[student_id] => 1012836002
[mentor_code] => TPA-1
[student_name] => Kesya
)
[2] => Array
(
[student_id] => 3012836003
[mentor_code] => TPA-1
[student_name] => Charissa
)
)
[E-2] => Array
(
[0] => Array
(
[student_id] => 1012836004
[mentor_code] => FIS-1
[student_name] => Drex
)
[1] => Array
(
[student_id] => 3012836005
[mentor_code] => FIS-1
[student_name] => Vulcano
)
)
)
[08:30-09:30] => Array
(
[E-1] => Array
(
[0] => Array
(
[student_id] => 1012836001
[mentor_code] => TPA-1
[student_name] => Vanessa
)
[1] => Array
(
[student_id] => 1012836002
[mentor_code] => TPA-1
[student_name] => Kesya
)
[2] => Array
(
[student_id] => 3012836003
[mentor_code] => TPA-1
[student_name] => Charissa
)
)
[E-2] => Array
(
[0] => Array
(
[student_id] => 1012836004
[mentor_code] => FIS-1
[student_name] => Drex
)
[1] => Array
(
[student_id] => 3012836005
[mentor_code] => FIS-1
[student_name] => Vulcano
)
)
)
[10:00-11:00] => Array
(
[E-1] => Array
(
[0] => Array
(
[student_id] => 1012836001
[mentor_code] => FIS-1
[student_name] => Vanessa
)
[1] => Array
(
[student_id] => 1012836002
[mentor_code] => FIS-1
[student_name] => Kesya
)
[2] => Array
(
[student_id] => 3012836003
[mentor_code] => FIS-1
[student_name] => Charissa
)
)
)
[11:00-12:00] => Array
(
[E-1] => Array
(
[0] => Array
(
[student_id] => 1012836001
[mentor_code] => FIS-1
[student_name] => Vanessa
)
[1] => Array
(
[student_id] => 1012836002
[mentor_code] => FIS-1
[student_name] => Kesya
)
[2] => Array
(
[student_id] => 3012836003
[mentor_code] => FIS-1
[student_name] => Charissa
)
)
)
)
Из массива я собираюсь создать таблицы примерно так:
Time : 07:30-08:30 TPA-1 Class : E-1
|------------|--------------|------------|
|Student ID | Student Name | Status |
|------------|--------------|------------|
|1012836001 | Vanessa | Check None |
|1012836002 | Kesya | Check None |
|3012836003 | Charissa | Check None |
|------------|--------------|------------|
Time : 08:30-09:30 TPA-1 Class : E-1
|------------|--------------|------------|
|Student ID | Student Name | Status |
|------------|--------------|------------|
|1012836001 | Vanessa | Check None |
|1012836002 | Kesya | Check None |
|3012836003 | Charissa | Check None |
|------------|--------------|------------|
Time : 07:30-08:30 FIS-1 Class : E-2
|------------|--------------|------------|
|Student ID | Student Name | Status |
|------------|--------------|------------|
|1012836004 | Drex | Check None |
|3012836005 | Vulcano | Check None |
|------------|--------------|------------|
Time : 08:30-09:30 FIS-1 Class : E-2
|------------|--------------|------------|
|Student ID | Student Name | Status |
|------------|--------------|------------|
|1012836004 | Drex | Check None |
|3012836005 | Vulcano | Check None |
|------------|--------------|------------|
Time : 10:00-11:00 FIS-1 Class : E-1
|------------|--------------|------------|
|Student ID | Student Name | Status |
|------------|--------------|------------|
|1012836001 | Vanessa | Check None |
|1012836002 | Kesya | Check None |
|3012836003 | Charissa | Check None |
|------------|--------------|------------|
Time : 11:00-12:00 FIS-1 Class : E-1
|------------|--------------|------------|
|Student ID | Student Name | Status |
|------------|--------------|------------|
|1012836001 | Vanessa | Check None |
|1012836002 | Kesya | Check None |
|3012836003 | Charissa | Check None |
|------------|--------------|------------|
Могу ли я получить результаты на основе моего массива? Мне действительно нужна помощь. Если кто-то здесь может указать мне правильное направление, был бы очень признателен. Спасибо.