/** * Table to string renderer * * @param array $body * @param array $headers_line * @param array $headers_column * @param string $title * @return string */ public static function tableToString(array $body, array $headers_line = array(), array $headers_column = array(), $title = '') { $table = new \Library\Tool\Table($body, $headers_line); if (!empty($headers_column)) { $table->addHeaderColumn($headers_column, 1); } $table::$default_foot_mask = !empty($title) ? $title : 'Encryption Table'; return $table->__toString(); }
echo "i={$i} : " . Library\Helper\Number::getFibonacciItem($i) . "\n"; } ?> </pre> <h3 id="tools">Library\Tool</h3> <p>The <var>Tools</var> of the package works around a specific type of data ; they are considered as <var>Helpers</var> but their methods are not static and they works just as a standalone simple class.</p> <h4 id="tabletool">Library\Tool\Table</h4> <pre class="code" data-language="php"> <?php $table_contents = array(0 => array('first item', 'second item', 'third item'), 1 => array('first item of second line', 'second item of second line', 'third item of second line')); $table_headers = array('first table header', 'second header', 'header'); $table = new Library\Tool\Table($table_contents, $table_headers, array(), null, Library\Tool\Table::PAD_BY_SPAN); $table->setTitle('My table title'); $table->addLine(array('a new line with', 'only two entries')); $table->addLine('a new line with only one entry'); $table->addLine(array('a new line with', 'more entries', 'than before', 'to test repadding')); echo '$table_contents = array(' . "\n" . "\t" . '0=>array("first item', 'second item", "third item"),' . "\n" . "\t" . '1=>array("first item of second line", "second item of second line", "third item of second line")' . "\n" . ');' . "\n"; echo '$table_headers = array(' . "\n" . "\t" . '"first table header", "second header", "header"' . "\n" . ');' . "\n"; echo '$table = new Library\\Tool\\Table($table_contents, $table_headers, array(), null, Library\\Tool\\Table::PAD_BY_SPAN);' . "\n"; echo '$table->setTitle("My table title");' . "\n"; echo '$table->addLine(array("a new line with", "only two entries"));' . "\n"; echo '$table->addLine("a new line with only one entry");' . "\n"; echo '$table->addLine(array("a new line with", "more entries", "than before", "to test repadding"));' . "\n"; echo "\n"; echo 'echo $table->getTable()' . "\n"; var_export($table->getTable()); ?>