PHP code example of entelisteam / lbaf-consoletable
1. Go to this page and download the library: Download entelisteam/lbaf-consoletable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use EntelisTeam\Lbaf\ConsoleTable\Align;
use EntelisTeam\Lbaf\ConsoleTable\ConsoleTable;
$table = ConsoleTable::fromRows($rows, returnObject: true);
$table->setAlign(2, Align::Right);
echo $table->getTable(); // или просто echo $table — есть __toString()
use EntelisTeam\Lbaf\ConsoleTable\Align;
use EntelisTeam\Lbaf\ConsoleTable\ConsoleTable;
$table = new ConsoleTable(
align: Align::Left, // выравнивание по умолчанию
border: ConsoleTable::BORDER_ASCII, // или свой символ рамки, '' — без рамки
padding: 1, // пробелы вокруг содержимого ячейки
charset: 'utf-8',
);
$table->setHeaders(['name', 'count']);
$table->addRow(['x', 2]);
$table->addRow(['y', 3.5]);
$table->addSeparator(); // горизонтальный разделитель
$table->addRow(['z', 1]);
$table->setAlign(1, Align::Right); // выравнивание конкретной колонки
$table->addFilter(0, strtoupper(...)); // callback к каждой ячейке колонки (заголовки не затрагивает)
$table->calculateTotalsFor([1]); // строка итогов по колонке 1
echo $table->getTable();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.