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

Class: Console_Table

Source Location: /Console_Table-1.2.1/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 194]

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 428]

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 447]

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 255]

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 391]

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 470]

void addSeparator( )

Adds a horizontal seperator to the table.

[ Top ]

calculateTotalsFor   [line 365]

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 226]

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 480]

string getTable( )

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

[ Top ]

insertRow   [line 412]

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 341]

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 ]

setBorder   [line 289]

void setBorder( mixed $border)

Set the table border settings

Border definition modes:

  • CONSOLE_TABLE_BORDER_ASCII: Default border with +, - and |
  • array with keys "intersection", "horizontal" and "vertical"
  • single character string that sets all three of the array keys

  • See: $_border

Parameters:

mixed   $border   —  Border definition

[ Top ]

setBorderVisibility   [line 319]

void setBorderVisibility( array $visibility)

Set which borders shall be shown.
  • See: $_borderVisibility

Parameters:

array   $visibility   —  Visibility settings. Allowed keys: left, right, top, bottom, inner

[ Top ]

setCharset   [line 268]

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 377]

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:59:24 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.