game/_incl_data/class/Helper/Table.php

21 lines
555 B
PHP
Raw Normal View History

2022-12-30 19:03:37 +00:00
<?php
namespace Helper;
2022-12-30 19:03:37 +00:00
class Table
{
public static function get($rows, $class = '', $fill = false): string
2022-12-30 19:03:37 +00:00
{
$c = '';
$maxRows = sizeof(max($rows));
2022-12-30 19:03:37 +00:00
foreach ($rows as $row) {
if ($fill && sizeof($row) < $maxRows) {
$row = array_merge($row, array_fill(0, $maxRows - sizeof($row), ''));
2022-12-30 19:03:37 +00:00
}
$c .= '<tr><td>' . implode('</td><td>', $row) . '</td></tr>';
}
return (!empty($class) ? "<table class='$class'>" : '<table>') . $c . '</table>' . PHP_EOL;
}
}