/** * Создать таблицу из массива * * @param array $rows массив строк таблицы (с тегами td) * @param array|string $table шапка таблицы * @param array $attr аттрибуты которые необходимо добавить к основному тегу table * @return string */ function html_table($rows, $table = '', array $attr = array()) { if (isset($table['head'])) { $thead = $table['head']; } elseif (is_array($table)) { $thead = html_implode($table, 'th'); } else { $thead = $table; } if (!empty($thead)) { $thead = html_wrap('thead', html_wrap('tr', $thead)); } return html_wrap('table', $thead . html_wrap('tbody', is_array($rows) ? html_implode($rows, 'tr') : $rows), $attr); }
function html_table_head($arr) { $html = html_implode($arr, 'th'); $html = '<tr>' . $html . '</tr>'; $html = '<thead>' . $html . '</thead>'; return $html; }