1. Go to this page and download the library: Download sauvank/php-console-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/ */
sauvank / php-console-table example snippets
use ConsoleTable\Table;
$columns = [
'column title', // By default, the size of the column is equal to the big string in title column or row.
[ // If you want define custom size for this column
'name' => 'release',
'size' => 10
]
];
$lines = [
[
"Fight club",
"1999-11-10"
],
[
"The lion king",
"2019-07-17"
],
];
// Optional
$conf = [
'margin' => 1, // int , Default : 1, set space character beetween limit column.
'showNumberRow' => true, // Bool, default : true, show the row number in table.
'defaultSizeCol' => 30, // int, default : 30, for size column if key size not set in $column array key.
];
$pt = new Table($columns, $lines, $conf);
$pt->show(); // Show all row of table
// Return trow error if index row not exist
$pt->showRow(2);
use ConsoleTable\Readline;
$txtToShow = "line to show :";
$userAnswer = new Readline($txtToShow);
use ConsoleTable\Readline;
$txtToShow = "line to show :";
$option = ["y", "n"];
$userAnswer = new Readline($txtToShow, $option);
use ConsoleTable\Readline;
$txtToShow = "line to show :";
$option = ["y", "n"]; // list of optino valid
$defaultValue = 0; // key index of the $option array.
$userAnswer = new Readline($txtToShow, $option, $defaultValue);
use ConsoleTable\Readline;
$readline= new Readline("line to show", ['1', '2']);
$confirm = $readline->confirm(); // return true or false
if($confirm){
echo "You have confirmed your choice " . $readline->getAnswer();
}else{
echo "You have not confirm your choice.\n";
}
`
use ConsoleTable\Readline;
$readline= new Readline(null);
$confirm = $readline->confirm(); // return true or false
if($confirm){
echo "You have confirmed your choice " . $readline->getAnswer();
}else{
echo "You have not confirm your choice.\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.