Вы можете решить эту задачу при помощи базы данных:
select
projects.id,
GROUP_CONCAT(if(day=1, name, null)) as Monday,
GROUP_CONCAT(if(day=2, name, null)) as Tuesday,
GROUP_CONCAT(if(day=3, name, null)) as Wednesday,
GROUP_CONCAT(if(day=4, name, null)) as Thursday,
GROUP_CONCAT(if(day=5, name, null)) as Friday,
GROUP_CONCAT(if(day=6, name, null)) as Saturday,
GROUP_CONCAT(if(day=7, name, null)) as Sunday
from projects
group by projects.id
;
Результат:
+====+========+=========+===========+==========+========+==========+========+
| id | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday |
+====+========+=========+===========+==========+========+==========+========+
| 1 | John | | | | | | |
+----+--------+---------+-----------+----------+--------+----------+--------+
| 2 | | | | Jack,Mike| | | |
+----+--------+---------+-----------+----------+--------+----------+--------+
Проверить
SQL запрос