Console_Table
[ class tree: Console_Table ] [ index: Console_Table ] [ all elements ]

Class: Console_Table

Source Location: /Console_Table-1.1.3/Table.php

Class Overview


The main class.


Author(s):

Methods


Inherited Variables

Inherited Methods


Class Details

[line 58]
The main class.


[ Top ]


Method Detail

Console_Table (Constructor)   [line 172]

Console_Table Console_Table( [integer $align = CONSOLE_TABLE_ALIGN_LEFT], [string $border = CONSOLE_TABLE_BORDER_ASCII], [integer $padding = 1], [string $charset = null], [boolean $color = false])

Constructor.

Parameters:

integer   $align   —  Default alignment. One of CONSOLE_TABLE_ALIGN_LEFT, CONSOLE_TABLE_ALIGN_CENTER or CONSOLE_TABLE_ALIGN_RIGHT.
string   $border   —  The character used for table borders or CONSOLE_TABLE_BORDER_ASCII.
integer   $padding   —  How many spaces to use to pad the table.
string   $charset   —  A charset supported by the mbstring PHP extension.
boolean   $color   —  Whether the data contains ansi color codes.

[ Top ]

addCol   [line 347]

void addCol( array $col_data, [integer $col_id = 0], [integer $row_id = 0])

Adds a column to the table.

Parameters:

array   $col_data   —  The data of the column.
integer   $col_id   —  The column index to populate.
integer   $row_id   —  If starting row is not zero, specify it here.

[ Top ]

addData   [line 366]

void addData( array $data, [integer $col_id = 0], [integer $row_id = 0])

Adds data to the table.

Parameters:

array   $data   —  A two dimensional array with the table data.
integer   $col_id   —  Starting column number.
integer   $row_id   —  Starting row number.

[ Top ]

addFilter   [line 228]

void addFilter( integer $col, mixed &$callback)

Adds a filter to a column.

Filters are standard PHP callbacks which are run on the data before table generation is performed. Filters are applied in the order they are added. The callback function must accept a single argument, which is a single table cell.


Parameters:

integer   $col   —  Column to apply filter to.
mixed   &$callback   —  PHP callback to apply.

[ Top ]

addRow   [line 310]

void addRow( array $row, [boolean $append = true])

Adds a row to the table.

Parameters:

array   $row   —  The row data to add.
boolean   $append   —  Whether to append or prepend the row.

[ Top ]

addSeparator   [line 389]

void addSeparator( )

Adds a horizontal seperator to the table.

[ Top ]

calculateTotalsFor   [line 284]

void calculateTotalsFor( array $cols)

Specifies which columns are to have totals calculated for them and added as a new row at the bottom.

Parameters:

array   $cols   —  Array of column numbers (starting with 0).

[ Top ]

fromArray   [line 199]

Console_Table|string fromArray( array $headers, array $data, [boolean $returnObject = false])

Converts an array to a table.
  • Return: A Console_Table object or the generated table.

Parameters:

array   $headers   —  Headers for the table.
array   $data   —  A two dimensional array with the table data.
boolean   $returnObject   —  Whether to return the Console_Table object instead of the rendered table.

[ Top ]

getTable   [line 399]

string getTable( )

Returns the generated table.
  • Return: The generated table.

[ Top ]

insertRow   [line 331]

void insertRow( array $row, [integer $row_id = 0])

Inserts a row after a given row number in the table.

If $row_id is not given it will prepend the row.


Parameters:

array   $row   —  The data to insert.
integer   $row_id   —  Row number to insert before.

[ Top ]

setAlign   [line 260]

void setAlign( integer $col_id, [integer $align = CONSOLE_TABLE_ALIGN_LEFT])

Sets the alignment for the columns.

Parameters:

integer   $col_id   —  The column number.
integer   $align   —  Alignment to set for this column. One of CONSOLE_TABLE_ALIGN_LEFT CONSOLE_TABLE_ALIGN_CENTER CONSOLE_TABLE_ALIGN_RIGHT.

[ Top ]

setCharset   [line 241]

void setCharset( string $charset)

Sets the charset of the provided table data.

Parameters:

string   $charset   —  A charset supported by the mbstring PHP extension.

[ Top ]

setHeaders   [line 296]

void setHeaders( array $headers)

Sets the headers for the columns.

Parameters:

array   $headers   —  The column headers.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:25:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.