src/GameOfLife/Utils/Shell/ShellTablePrinter.php
/**
     * Prints a table to the console.
     *
     * @param String[][] $_tableRows The table rows in the format array(0 => array("fieldA", "fieldB"))
     * @param int $_paddingOnAutoLineBreak The amount of padding for every new line
     * @param int[] $_columnWidthPercentages The custom column width percentages in the format array("x" => "percentage")
     * @param bool $_lineBreakOnEmptyWord Indicates whether the line breaks will only be placed between words
     */
Prints a table to the console.
Prints a table to the console .
public function printTable(array $_tableRows, int $_paddingOnAutoLineBreak = 0, array $_columnWidthPercentages = null, bool $_lineBreakOnEmptyWord = false)
    {
        $columnWidths = $this->getTableColumnWidths(count($_tableRows[0]), $_columnWidthPercentages);
        foreach ($_tableRows as $y => $row)
        {
            $subFields = array();
            foreach ($row as $x => $field)
            {
                $fieldSubRows = $this->getFieldSubRows($field, $columnWidths[$x], $_paddingOnAutoLineBreak, $_lineBreakOnEmptyWord);
                foreach ($fieldSubRows as $subY => $subField)
                {
                    $subFields[$subY][$x] = $subField;
                }
            }
            foreach ($subFields as $subY => $subRow)
            {
                foreach ($subRow as $subX => $subField)
                {
                    echo str_pad($subField, $columnWidths[$subX]);
                }
                echo "\n";
            }
        }
    }
public function printTable ( array $ _tableRows , int $ _paddingOnAutoLineBreak = 0 , array $ _columnWidthPercentages = null , bool $ _lineBreakOnEmptyWord = false ) { $ columnWidths = $ this -> getTableColumnWidths ( count ( $ _tableRows [ 0 ] ) , $ _columnWidthPercentages ) ; foreach ( $ _tableRows as $ y => $ row ) { $ subFields = array ( ) ; foreach ( $ row as $ x => $ field ) { $ fieldSubRows = $ this -> getFieldSubRows ( $ field , $ columnWidths [ $ x ] , $ _paddingOnAutoLineBreak , $ _lineBreakOnEmptyWord ) ; foreach ( $ fieldSubRows as $ subY => $ subField ) { $ subFields [ $ subY ] [ $ x ] = $ subField ; } } foreach ( $ subFields as $ subY => $ subRow ) { foreach ( $ subRow as $ subX => $ subField ) { echo str_pad ( $ subField , $ columnWidths [ $ subX ] ) ; } echo " \n " ; } } }
Prints a table to the console.
Prints a table to the console .
// Print the table