21 lines
555 B
PHP
21 lines
555 B
PHP
<?php
|
|
|
|
namespace Helper;
|
|
|
|
class Table
|
|
{
|
|
public static function get($rows, $class = '', $fill = false): string
|
|
{
|
|
$c = '';
|
|
$maxRows = sizeof(max($rows));
|
|
|
|
foreach ($rows as $row) {
|
|
if ($fill && sizeof($row) < $maxRows) {
|
|
$row = array_merge($row, array_fill(0, $maxRows - sizeof($row), ''));
|
|
}
|
|
$c .= '<tr><td>' . implode('</td><td>', $row) . '</td></tr>';
|
|
}
|
|
|
|
return (!empty($class) ? "<table class='$class'>" : '<table>') . $c . '</table>' . PHP_EOL;
|
|
}
|
|
} |