PHP code example of vansales / uconvert

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

    

vansales / uconvert example snippets


$convert = new vansales\Uconvert;


// Initial set of Unit Conversion
$baseUnit = 'ชิ้น';

$convrtSet = array(
    'unit1' => 'แพ็ค',
    'unit2' => 'โหล',
    'unit3' => '',
    'conv1' => 6,
    'conv2' => 12,
    'conv3' => 0,
);

$convert->init($baseUnit, $convrtSet);


$convert->setQty(59);
$result = $convert->from_baseUnit();
print_r($result);


$convert->setQty(15);
$convert->setUnit('ลัง');
$result = $convert->to_baseUnit();
print_r($result);