-
Notifications
You must be signed in to change notification settings - Fork 2
/
example-weekdays.php
executable file
·33 lines (25 loc) · 1.06 KB
/
example-weekdays.php
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
#!/usr/bin/env php
<?php
require_once( __DIR__ . '/texttable.class.php' );
$data = [
['Weekday', 'Abbrev', 'Initial', 'Position'],
['Sunday', 'Sun', 'S', '0'],
['Monday', 'Mon', 'M', '1'],
['Tuesday', 'Tue', 'T', '2'],
['Wednesday', 'Wed', 'W', '3'],
['Thursday', 'Thu', 'T', '4'],
['Friday', 'Fri', 'F', '5'],
['Saturday', 'Sat', 'S', '6'],
];
echo " [ Table with header from first row values ]\n";
echo texttable::table( $data, $headertype = 'firstrow' );
// Display header from keys instead. ( default behavior )
$footer = array_shift( $data ); // remove first and second row.
array_shift( $data );
array_unshift( $data, ['weekday' => 'Sunday', 'abbrev' => 'Sun', 'initial' => 'S', 'position' => 0] );
echo "\n\n [ Example 2. Table with header generated from array keys ]\n";
echo texttable::table( $data );
// Add a footer row, same as header, but displaying values instead of keys.
$data[] = $footer;
echo "\n\n [ Example 3. Table with header (array keys) and footer ( array vals ) ]\n";
echo texttable::table( $data, $headertype = 'keys', $footertype = 'lastrow' );