1. Go to this page and download the library: Download zenstruck/dimension 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/ */
zenstruck / dimension example snippets
use Zenstruck\Dimension;
// create
$dimension = new Dimension(45.458, 'ft');
$dimension = Dimension::from('45.458ft'); // equivalent to above
$dimension->quantity(); // 45.458
$dimension->unit(); // "ft"
// render
$dimension->toString(); // "45.46 ft" (max 2 decimal places)
(string) $dimension; // equivalent to above
$dimension->toArray(); // [45.458, "ft"]
json_encode($dimension); // '[45.458, "ft"]'
// use your own formatter
vsprintf('%.4f%s', $dimension->toArray()); // "45.4580ft"
use Zenstruck\Dimension\Information;
$info = Information::from('4568897B');
$info = Information::from(4568897); // equivalent to above (can create from bytes directly)
$info->bytes(); // 4568897
// "humanize"
(string) $info->humanize(); // "4.57 MB" (defaults to the decimal system)
(string) $info->asBinary()->humanize(); // "4.36 MiB" (convert to binary system before humanizing)
(string) Information::binary(4568897)->humanize(); // "4.36 MiB" (explicitly create in binary system)
// when creating with a unit of measure, the system is detected
(string) Information::from('4570 kb')->humanize(); // "4.57 MB"
(string) Information::from('4570 KiB')->humanize(); // "4.46 MiB"