fetchAll(" select g.DATE , g.L_APPOITMENT_USER , g.WORKER_COMMENT -- , g.* from GRAFIK_PRACY g where g.L_APPOITMENT_USER in ( 'sokol', 'm.kwiatkowski', 'kacper.klimanski' ) and g.DATE like '2019-10-%' and g.WORKER_COMMENT != '' "); $rozliczList = array_reduce($rows, function ($ret, $item) { $splitTasks = explode("\n", $item['WORKER_COMMENT']); foreach ($splitTasks as $commentLine) { $commentLine = trim($commentLine); if (empty($commentLine)) continue; $ret[] = array_merge($item, [ 'WORKER_COMMENT' => $commentLine, ]); } return $ret; }, []); // UI::table([ // 'rows' => $rows, // ]); // UI::table([ // 'rows' => $rozliczList, // ]); $rozliczByDayList = array_reduce($rozliczList, function ($ret, $item) { $day = $item['DATE']; if (array_key_exists($ret, $day)) $ret[$day] = []; $ret[$day][] = $item; return $ret; }, []); // [ day => [] ] ksort($rozliczByDayList); echo UI::h('div', [], array_map(function ($item, $day) { return UI::h('div', [], [ UI::h('h3', [], "DzieƄ: {$day}"), UI::hTable([ 'rows' => $item ]), ]); }, $rozliczByDayList, array_keys($rozliczByDayList))); } }