1. Go to this page and download the library: Download pleets/units-of-measurement 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/ */
pleets / units-of-measurement example snippets
use Pleets\Units\Symbols\TimeSymbol;
use Pleets\Units\Units\TimeUnit;
use Pleets\Units\Symbols\InformationSymbol;
use Pleets\Units\Units\InformationUnit;
// second
$symbol = TimeUnit::fromSymbol(TimeSymbol::SECOND);
// kilobyte
$symbol = InformationUnit::fromSymbol(InformationSymbol::KILOBYTE);
use Pleets\Units\Symbols\TimeSymbol;
use Pleets\Units\Units\TimeUnit;
use Pleets\Units\Symbols\InformationSymbol;
use Pleets\Units\Units\InformationUnit;
// s
$symbol = TimeSymbol::fromUnit(TimeUnit::SECOND);
// KB
$symbol = InformationSymbol::fromUnit(InformationUnit::KILOBYTE);
use Pleets\Units\Units\TimeUnit;
use Pleets\Units\Units\Sets\TimeUnitSet;
$timeSet = new TimeUnitSet();
$timeSet->addUnit(TimeUnit::MINUTE);
$timeSet->addUnit(TimeUnit::HOUR);
// ['minute', 'hour']
$units = $timeSet->toArray();
use Pleets\Units\Symbols\TimeSymbol;
use Pleets\Units\Symbols\Sets\TimeSymbolSet;
$timeSet = new TimeSymbolSet();
$timeSet->addSymbol(TimeSymbol::MINUTE);
$timeSet->addSymbol(TimeSymbol::HOUR);
// ['min', 'h']
$symbols = $timeSet->toArray();