src/Benchmark.php
public function outputTable(array $lines, $padding = 4)
    {
        $pad = function ($string, $width) use ($padding) {
            if ($width > 0) {
                return str_pad($string, $width, ' ') . str_repeat(' ', $padding);
            } else {
                return str_pad($string, -$width, ' ', STR_PAD_LEFT) . str_repeat(' ', $padding);
            }
        };

        // init width with keys' length
        $cols = array_combine(
            array_keys($lines[0]),
            array_map('strlen', array_keys($lines[0]))
        );

        foreach ($cols as $col => $width) {

            foreach ($lines as $line) {
                $width = max($width, strlen($line[$col]));
            }

            if ($col !== self::COL_NAME) {
                $width = -$width;
            }

            $this->out($pad($col, $width), false);
            $cols[$col] = $width;
        }

        $this->out('');

        foreach ($lines as $line) {
            foreach ($cols as $col => $width) {
                $this->out($pad($line[$col], $width), false);
            }
            $this->out('');
        }
    }
public function outputTable(array $lines, $padding = 4)
    {
        $pad = function ($string, $width) use ($padding) {
            if ($width > 0) {
                return str_pad($string, $width, ' ') . str_repeat(' ', $padding);
            } else {
                return str_pad($string, -$width, ' ', STR_PAD_LEFT) . str_repeat(' ', $padding);
            }
        };

        // init width with keys' length
        $cols = array_combine(
            array_keys($lines[0]),
            array_map('strlen', array_keys($lines[0]))
        );

        foreach ($cols as $col => $width) {

            foreach ($lines as $line) {
                $width = max($width, strlen($line[$col]));
            }

            if ($col !== self::COL_NAME) {
                $width = -$width;
            }

            $this->out($pad($col, $width), false);
            $cols[$col] = $width;
        }

        $this->out('');

        foreach ($lines as $line) {
            foreach ($cols as $col => $width) {
                $this->out($pad($line[$col], $width), false);
            }
            $this->out('');
        }
    }
public function outputTable ( array $ lines , $ padding = 4 ) { $ pad = function ( $ string , $ width ) use ( $ padding ) { if ( $ width > 0 ) { return str_pad ( $ string , $ width , ' ' ) . str_repeat ( ' ' , $ padding ) ; } else { return str_pad ( $ string , - $ width , ' ' , STR_PAD_LEFT ) . str_repeat ( ' ' , $ padding ) ; } } ; // init width with keys' length $ cols = array_combine ( array_keys ( $ lines [ 0 ] ) , array_map ( 'strlen' , array_keys ( $ lines [ 0 ] ) ) ) ; foreach ( $ cols as $ col => $ width ) { foreach ( $ lines as $ line ) { $ width = max ( $ width , strlen ( $ line [ $ col ] ) ) ; } if ( $ col !== self :: COL_NAME ) { $ width = - $ width ; } $ this -> out ( $ pad ( $ col , $ width ) , false ) ; $ cols [ $ col ] = $ width ; } $ this -> out ( '' ) ; foreach ( $ lines as $ line ) { foreach ( $ cols as $ col => $ width ) { $ this -> out ( $ pad ( $ line [ $ col ] , $ width ) , false ) ; } $ this -> out ( '' ) ; } }
Output results in columns, padding right if values are string, left if numeric

@param  array   $lines   array(array('Name' => 'Value'));
@param  integer $padding space between columns
Output results in columns padding right if values are string left if numeric