PHP code example of rodrigopedra / table-stream

1. Go to this page and download the library: Download rodrigopedra/table-stream 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/ */

    

rodrigopedra / table-stream example snippets




odrigopedra\TableStream\Column;
use Rodrigopedra\TableStream\Table;

$table = new Table([
    // first parameter is the column's header
    // second is your estimated cell width
    // third is the cell alignment
    new Column('#', 8, Column::ALIGN_CENTER),

    // Column::ALIGN_LEFT is the default alignment
    new Column('Date', 19),

    // Fluent "wither" method are also avaialable
    Column::make('Value')->width(13)->alignRight(),
]);

// re-writes header overy 5 rows
$table->offset(5);

foreach (\range(1, 10) as $index) {
    $table->appendRow([
        \number_format($index),
        \date('Y-m-d H:i:s'),
        \uniqid(),
    ]);

    \sleep(1);
}

$table->close();