src/Console/ConsoleFormatter.php
public function alignText($array, $delimiter = '')
    {
        // Get max column widths
        $widths = [];
        foreach ($array as $row) {
            $lengths = array_map('strlen', $row);

            for ($i = 0; $i < count($lengths); $i++) {
                if (isset($widths[$i])) {
                    $widths[$i] = max($widths[$i], $lengths[$i]);
                } else {
                    $widths[$i] = $lengths[$i];
                }
            }
        }

        // Pad lines columns and return an array
        $output = [];
        foreach($array as $row) {
            $entries = [];
            for ($i = 0; $i < count($row); $i++) {
                $entries[] = str_pad($row[$i], $widths[$i]);
            }

            $output[] = implode($entries, $delimiter);
        }

        return $output;
    }
public function alignText($array, $delimiter = '')
    {
        // Get max column widths
        $widths = [];
        foreach ($array as $row) {
            $lengths = array_map('strlen', $row);

            for ($i = 0; $i < count($lengths); $i++) {
                if (isset($widths[$i])) {
                    $widths[$i] = max($widths[$i], $lengths[$i]);
                } else {
                    $widths[$i] = $lengths[$i];
                }
            }
        }

        // Pad lines columns and return an array
        $output = [];
        foreach($array as $row) {
            $entries = [];
            for ($i = 0; $i < count($row); $i++) {
                $entries[] = str_pad($row[$i], $widths[$i]);
            }

            $output[] = implode($entries, $delimiter);
        }

        return $output;
    }
public function alignText ( $ array , $ delimiter = '' ) { // Get max column widths $ widths = [ ] ; foreach ( $ array as $ row ) { $ lengths = array_map ( 'strlen' , $ row ) ; for ( $ i = 0 ; $ i < count ( $ lengths ) ; $ i ++ ) { if ( isset ( $ widths [ $ i ] ) ) { $ widths [ $ i ] = max ( $ widths [ $ i ] , $ lengths [ $ i ] ) ; } else { $ widths [ $ i ] = $ lengths [ $ i ] ; } } } // Pad lines columns and return an array $ output = [ ] ; foreach ( $ array as $ row ) { $ entries = [ ] ; for ( $ i = 0 ; $ i < count ( $ row ) ; $ i ++ ) { $ entries [ ] = str_pad ( $ row [ $ i ] , $ widths [ $ i ] ) ; } $ output [ ] = implode ( $ entries , $ delimiter ) ; } return $ output ; }
Given a multidimensional array, formats the text such that each entry
is left aligned with all other entries in the given column. The method
also takes an optional delimiter for specifying a sequence of characters
to separate each column.

@param  array  $array     The multidimensional array to format
@param  string $delimiter The delimiter to be used between columns
@return array  An array of strings containing the formatted entries
Given a multidimensional array formats the text such that each entry is left aligned with all other entries in the given column . The method also takes an optional delimiter for specifying a sequence of characters to separate each column .