Converts number of bytes to human readable number by taking the number of that unit that the bytes will go into it.
Via Composer:
$ composer require ravjanisz/readablesize
// add settings instance
use Rav\Size\SizeSettings;
// add instance
use Rav\Size\Size;
//base for calculation can be added as SizeSettings constructor parameter
//SizeSettings::BINARY or SizeSettings::DECIMAL
$settings = new SizeSettings();
//set precision for size
$settings->setPrecision(2);
//new object instance
$this->size = new Size($settings);
//return '1.46KiB'
echo $this->size->human('1500');
//convert size
//return '0.01TiB'
echo $this->size->convert(Size::MB, Size::TB, '9500');
None
Do you like this project? Support it by donating
<a href="https://www.buymeacoffee.com/ravjanisz">
</a>
readablesize is licensed under the MIT License - see the LICENSE file for details
Classes of Rafal Janisz | > | PHP Human Readable File Size | > | ![]() |
> | ![]() |
> | ![]() |
> | ![]() ![]() |
|
|
Groups | Applications | ![]() |
Groups |
![]() |
Classes using PHP 5 specific features | View top rated classes |
![]() |
Manipulating and validating text data | View top rated classes |
![]() |
Unit and datatype conversion | View top rated classes |
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
![]() NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
|