Editor PHP 2.4.0

Table
in package

Provides helpers to display a table.

Tags
author

Fabien Potencier fabien@symfony.com

author

Саша Стаменковић umpirsky@gmail.com

author

Abdellatif Ait boudad a.aitboudad@gmail.com

author

Max Grigorian maxakawizard@gmail.com

author

Dany Maillard danymaillard93b@gmail.com

Table of Contents

Methods

__construct()  : mixed
addRow()  : $this
addRows()  : $this
appendRow()  : $this
Adds a row to the table, and re-renders the table.
getColumnStyle()  : TableStyle
Gets the current style for a column.
getStyle()  : TableStyle
Gets the current table style.
getStyleDefinition()  : TableStyle
Gets a style definition by name.
render()  : void
Renders table to output.
setColumnMaxWidth()  : $this
Sets the maximum width of a column.
setColumnStyle()  : $this
Sets table column style.
setColumnWidth()  : $this
Sets the minimum width of a column.
setColumnWidths()  : $this
Sets the minimum width of all columns.
setFooterTitle()  : $this
setHeaders()  : $this
setHeaderTitle()  : $this
setHorizontal()  : $this
setRow()  : $this
setRows()  : $this
setStyle()  : $this
Sets table style.
setStyleDefinition()  : void
Sets a style definition.
setVertical()  : $this

Methods

addRows()

public addRows(array<string|int, mixed> $rows) : $this
Parameters
$rows : array<string|int, mixed>
Return values
$this

appendRow()

Adds a row to the table, and re-renders the table.

public appendRow(TableSeparator|array<string|int, mixed> $row) : $this
Parameters
$row : TableSeparator|array<string|int, mixed>
Return values
$this

getColumnStyle()

Gets the current style for a column.

public getColumnStyle(int $columnIndex) : TableStyle

If style was not set, it returns the global table style.

Parameters
$columnIndex : int
Return values
TableStyle

getStyleDefinition()

Gets a style definition by name.

public static getStyleDefinition(string $name) : TableStyle
Parameters
$name : string
Return values
TableStyle

render()

Renders table to output.

public render() : void

Example:

+---------------+-----------------------+------------------+ | ISBN | Title | Author | +---------------+-----------------------+------------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | +---------------+-----------------------+------------------+

setColumnMaxWidth()

Sets the maximum width of a column.

public setColumnMaxWidth(int $columnIndex, int $width) : $this

Any cell within this column which contents exceeds the specified width will be wrapped into multiple lines, while formatted strings are preserved.

Parameters
$columnIndex : int
$width : int
Return values
$this

setColumnStyle()

Sets table column style.

public setColumnStyle(int $columnIndex, TableStyle|string $name) : $this
Parameters
$columnIndex : int
$name : TableStyle|string

The style name or a TableStyle instance

Return values
$this

setColumnWidth()

Sets the minimum width of a column.

public setColumnWidth(int $columnIndex, int $width) : $this
Parameters
$columnIndex : int
$width : int
Return values
$this

setColumnWidths()

Sets the minimum width of all columns.

public setColumnWidths(array<string|int, mixed> $widths) : $this
Parameters
$widths : array<string|int, mixed>
Return values
$this

setFooterTitle()

public setFooterTitle(string|null $title) : $this
Parameters
$title : string|null
Return values
$this

setHeaders()

public setHeaders(array<string|int, mixed> $headers) : $this
Parameters
$headers : array<string|int, mixed>
Return values
$this

setHeaderTitle()

public setHeaderTitle(string|null $title) : $this
Parameters
$title : string|null
Return values
$this

setHorizontal()

public setHorizontal([bool $horizontal = true ]) : $this
Parameters
$horizontal : bool = true
Return values
$this

setRow()

public setRow(int|string $column, array<string|int, mixed> $row) : $this
Parameters
$column : int|string
$row : array<string|int, mixed>
Return values
$this

setRows()

public setRows(array<string|int, mixed> $rows) : $this
Parameters
$rows : array<string|int, mixed>
Return values
$this

setStyle()

Sets table style.

public setStyle(TableStyle|string $name) : $this
Parameters
$name : TableStyle|string
Return values
$this

setStyleDefinition()

Sets a style definition.

public static setStyleDefinition(string $name, TableStyle $style) : void
Parameters
$name : string
$style : TableStyle

setVertical()

public setVertical([bool $vertical = true ]) : $this
Parameters
$vertical : bool = true
Return values
$this

        
On this page

Search results