PHP code example of mistralys / column-widths-calculator

1. Go to this page and download the library: Download mistralys/column-widths-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/ */

    

mistralys / column-widths-calculator example snippets



$columns = array(
    'Col1' => 20,
    'Col2' => 0,
    'Col3' => 40
);

$calc =  Calculator::create($columns);

$converted = $calc->getValues();

array(
    'Col1' => 20,
    'Col2' => 40,
    'Col3' => 40
);

$calc = Calculator::create($columns);
$calc->setFloatValues();

$calc = Calculator::create($columns);
$calc->setMinWidth(20);

$calc = Calculator::create($columns);
$calc->setMaxTotal(1000);

$cols = array(
    'Col1' => 40,
    'Col2' => 40,
    'Col3' => 20
);

$calc = Calculator::create($columns);

$pixelWidths = $calc->getPixelValues(600);

Col1 = 38
Col2 = 33
Col3 = 30

= 100%