src/mako/cli/output/helpers/Table.php
protected function getColumnWidths(array $columnNames, array $rows): array
	{
		$columnWidths = [];

		// First we'll get the width of the column names

		foreach(array_values($columnNames) as $key => $value)
		{
			$columnWidths[$key] = $this->stringWidthWithoutFormatting($value);
		}

		// Then we'll go through each row and check if the cells are wider than the column names

		foreach($rows as $row)
		{
			foreach(array_values($row) as $key => $value)
			{
				$width = $this->stringWidthWithoutFormatting($value);

				if($width > $columnWidths[$key])
				{
					$columnWidths[$key] = $width;
				}
			}
		}

		// Return array of column widths

		return $columnWidths;
	}
protected function getColumnWidths(array $columnNames, array $rows): array
	{
		$columnWidths = [];

		// First we'll get the width of the column names

		foreach(array_values($columnNames) as $key => $value)
		{
			$columnWidths[$key] = $this->stringWidthWithoutFormatting($value);
		}

		// Then we'll go through each row and check if the cells are wider than the column names

		foreach($rows as $row)
		{
			foreach(array_values($row) as $key => $value)
			{
				$width = $this->stringWidthWithoutFormatting($value);

				if($width > $columnWidths[$key])
				{
					$columnWidths[$key] = $width;
				}
			}
		}

		// Return array of column widths

		return $columnWidths;
	}
protected function getColumnWidths ( array $ columnNames , array $ rows ) : array { $ columnWidths = [ ] ; // First we'll get the width of the column names foreach ( array_values ( $ columnNames ) as $ key => $ value ) { $ columnWidths [ $ key ] = $ this -> stringWidthWithoutFormatting ( $ value ) ; } // Then we'll go through each row and check if the cells are wider than the column names foreach ( $ rows as $ row ) { foreach ( array_values ( $ row ) as $ key => $ value ) { $ width = $ this -> stringWidthWithoutFormatting ( $ value ) ; if ( $ width > $ columnWidths [ $ key ] ) { $ columnWidths [ $ key ] = $ width ; } } } // Return array of column widths return $ columnWidths ; }
Returns an array containing the maximum width of each column.

@param  array $columnNames Array of column names
@param  array $rows        Array of rows
@return array
Returns an array containing the maximum width of each column .