Console_Table examples

Table of Contents

To get the feeling how Console_Table is used, try out the following examples.

A very simple example

Here we are following the basic steps to get some data out on the shell:

  • Creating a Console_Table object

  • Adding the header row

  • Adding some data rows

  • Rendering the table to the shell

<?php
require_once 'Console/Table.php';

$tbl = new Console_Table();
$tbl->setHeaders(
    array(
'Language''Year')
);
$tbl->addRow(array('PHP'1994));
$tbl->addRow(array('C',   1970));
$tbl->addRow(array('C++'1983));

echo 
$tbl->getTable();
?>

This examples would display as following:


+----------+------+
| Language | Year |
+----------+------+
| PHP      | 1994 |
| C        | 1970 |
| C++      | 1983 |
+----------+------+
Introduction to Console_Table (Previous) Using column filtering with Console_Color (Next)
Last updated: Thu, 28 Aug 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.