PHP code example of cmfcmf / column-width-calculator
1. Go to this page and download the library: Download cmfcmf/column-width-calculator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cmfcmf / column-width-calculator example snippets
/**
* @param array $rows An array of rows, where each row is an array of cells containing the cell content.
* @param bool $html Whether or not the rows contain html content. This will call html_entity_decode.
* @param bool $stripTags Whether or not to strip tags (only if $html is true).
* @param int $minPercentage The minimum percentage each row must be wide.
* @param null $customColumnFunction A custom function to transform a cell's value before it's length is measured.
*/
$columnWidthCalculator = new Cmfcmf\ColumnWidthCalculator($rows);
/**
* Calculate the column widths.
*
* @return array
*
* Explanation of return array:
* - $columnSizes[$colNumber]['percentage'] The calculated column width in percents.
* - $columnSizes[$colNumber]['calc'] The calculated column width in letters.
*
* - $columnSizes[$colNumber]['max'] The maximum column width in letters.
* - $columnSizes[$colNumber]['avg'] The average column width in letters.
* - $columnSizes[$colNumber]['raw'] An array of all the column widths of this column in letters.
* - $columnSizes[$colNumber]['stdd'] The calculated standard deviation in letters.
*
* INTERNAL
* - $columnSizes[$colNumber]['cv'] The calculated standard deviation / the average column width in letters.
* - $columnSizes[$colNumber]['stdd/max'] The calculated standard deviation / the maximum column width in letters.
*/
$columnSizes = $columnWidthCalculator->calculateWidths();