PHP code example of lucasjs7 / simple-cli-table

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

    

lucasjs7 / simple-cli-table example snippets


# Code:
$data = [
	['First Name', 'Last Name', 'Age'],
	['Steve',      'Magal',     '37'],
	['Jorel',      'Seila',     '14'],
	['William',    'Shostners', '9'],
	['Carlos',     'Felino',    '39'],
];

echo SimpleCliTable::build($data);

# Output:
+------------+-----------+-----+
| First Name | Last Name | Age |
+------------+-----------+-----+
| Steve      | Magal     | 37  |
| Jorel      | Seila     | 14  |
| William    | Shostners | 9   |
| Carlos     | Felino    | 39  |
+------------+-----------+-----+

# Code:
$data = [
	['Steve',      'Magal',     '37'],
	['Jorel',      'Seila',     '14'],
	['William',    'Shostners', '9'],
	['Carlos',     'Felino',    '39'],
];

$simpleTableCli = new SimpleCliTable;
$simpleTableCli->setContainsHeader(false);

foreach ($data as $line) {
	$simpleTableCli->add($line);
}

echo $simpleTableCli->render();

# Output:
+---------+-----------+----+
| Steve   | Magal     | 37 |
| Jorel   | Seila     | 14 |
| William | Shostners | 9  |
| Carlos  | Felino    | 39 |
+---------+-----------+----+

composer