PHP code example of doghouse-agency / php-table-multiformat

1. Go to this page and download the library: Download doghouse-agency/php-table-multiformat 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/ */

    

doghouse-agency / php-table-multiformat example snippets




use \PHPTable\Format\HumanOnly;

// $data used below is an array of rows with fields. See tests/data.php for an example.

$tablemaker = new \PHPTable\Factory();
$table = $tablemaker->make('human-only');
$table->setTableColor('blue');
$table->setHeaderColor('cyan');
$table->addField('First Name', 'firstName',    false,                               'white');
$table->addField('Last Name',  'lastName',     false,                               'white');
$table->addField('DOB',        'dobTime',      new \PHPTable\Manipulator\Base('datelong'));
$table->addField('Admin',      'isAdmin',      new \PHPTable\Manipulator\Base('yesno'),    'yellow');
$table->addField('Last Seen',  'lastSeenTime', new \PHPTable\Manipulator\Base('nicetime'), 'red');
$table->addField('Expires',    'expires',      new \PHPTable\Manipulator\Base('duetime'),  'green');
$table->injectData($data);
$table->display();

class MyManipulator extends \PHPTable\Manipulator\Base {
	public function chucknorris($value)
	{
		return 'Chuck norris said: ' . $value;
	}
}

$tablemaker = new \PHPTable\Factory();
$table = $tablemaker->make('human-only');
$table->setTableColor('blue');
$table->setHeaderColor('cyan');
$table->addField('First Name', 'firstName',    false,                               'white');
$table->addField('Last Name',  'lastName',     false,                               'white');
$table->addField('DOB',        'dobTime',      new \PHPTable\Manipulator\Base('datelong'));
$table->addField('Admin',      'isAdmin',      new MyManipulator('chucknorris'),    'yellow');
$table->addField('Last Seen',  'lastSeenTime', new \PHPTable\Manipulator\Base('nicetime'), 'red');
$table->addField('Expires',    'expires',      new \PHPTable\Manipulator\Base('duetime'),  'green');
$table->injectData($data);
$table->display();

$wrapper = new \PHPTable\Manipulator\TextWidth(
	max_width: 30,
	wrapping: 'clip',
);
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php