jschaedl / byte
byte conversion utility
Installs: 16 997
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 1
Open Issues: 0
Requires (Dev)
- covex-nn/phpcb: 1.0.*@dev
- pdepend/pdepend: dev-master
- phpdocumentor/phpdocumentor: *
- phploc/phploc: *
- phpmd/phpmd: dev-master
- phpunit/php-code-coverage: >=1.2.10,<1.3.0
- phpunit/phpunit: 3.7.*
- sebastian/phpcpd: *
- zerkalica/phpcs: dev-master
This package is auto-updated.
Last update: 2024-09-29 04:08:40 UTC
README
A simple byte conversion utility to make conversion of byte values easier! It is built for PHP 5.3+.
Installation
Install the library using composer. Add the following to your composer.json
:
"require": {
"jschaedl/byte": "dev-master"
}
And run the composer install command in terminal.
sudo composer.phar install
Usage example
<?php
$converter = new \Byte\ByteConverter();
// convert to bytes
$converter->getBytes('1b'); // 1
$converter->getBytes('1k'); // 1024
$converter->getBytes('1m'); // 1048576
$converter->getBytes('1g'); // 1073741824
// convert to kilobytes
$converter->getKBytes('1b'); // 0.0009765625
$converter->getKBytes('1k'); // 1
$converter->getKBytes('1m'); // 1024
$converter->getKBytes('1g'); // 1048576
// convert to megabytes
$converter->getMBytes('1b'); // 0.00000095367431640625
$converter->getMBytes('1k'); // 0.0009765625
$converter->getMBytes('1m'); // 1
$converter->getMBytes('1g'); // 1024
// convert to gigabytes
$converter->getGBytes('1b'); // 0.00000000093132257461548
$converter->getGBytes('1k'); // 0.00000095367431640625
$converter->getGBytes('1m'); // 0.0009765625
$converter->getGBytes('1g'); // 1
Author
License
MIT Public License