File: tutorial_example_10_table_advanced.php

package info (click to toggle)
php-zeta-console-tools 1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,096 kB
  • ctags: 2,859
  • sloc: php: 15,140; xml: 3,111; makefile: 11
file content (38 lines) | stat: -rw-r--r-- 1,024 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

require_once 'tutorial_autoload.php';

$output = new ezcConsoleOutput();

$output->formats->blue->color  = 'blue';
$output->formats->blue->style = array(  'bold' );
$output->formats->red->color   = 'red';
$output->formats->red->style = array(  'bold' );
$output->formats->green->color = 'green';
$output->formats->green->style = array(  'bold' );

$colors = array( 'red', 'blue', 'green' );
$aligns = array( ezcConsoleTable::ALIGN_LEFT, ezcConsoleTable::ALIGN_CENTER, ezcConsoleTable::ALIGN_RIGHT );

$table = new ezcConsoleTable( $output, 78 );

$table->options->corner = ' ';
$table->options->lineHorizontal = ' ';
$table->options->lineVertical = ' ';
$table->options->widthType = ezcConsoleTable::WIDTH_FIXED;

for ( $i = 0; $i < 10; $i++ )
{
    for ( $j = 0; $j < 10; $j++ )
    {
        $table[$i][$j]->content = '*';
        $table[$i][$j]->format  = $colors[array_rand( $colors )];
        $table[$i][$j]->align   = $aligns[array_rand( $aligns )];
    }
}

$table->outputTable();
$output->outputLine();


?>