<?php
use Laminas\Text\Table\Table;
use Laminas\Text\Table\Row;
// every row needs same row count
$data = [
['Number', 'Int', 'Even'],
['one', '1', 'no'],
['two', '2', 'yes'],
['three', '3', 'no'],
['four', '4', 'yes'],
];
$table = new Table(
// width in chars
['columnWidths' => [6,5,5]]
);
foreach($data as $row)
{
$rowObj = new Row();
foreach($row as $column) {
$rowObj->createColumn($column);
}
// appending $row is possible too
$table->appendRow($rowObj);
}
echo '<pre>' . $table . '</pre>';
┌──────┬─────┬─────┐ │Number│Int │Even │ ├──────┼─────┼─────┤ │one │1 │no │ ├──────┼─────┼─────┤ │two │2 │yes │ ├──────┼─────┼─────┤ │three │3 │no │ ├──────┼─────┼─────┤ │four │4 │yes │ └──────┴─────┴─────┘