Filesize To Human Friendly

1.1 2022-03-07 20:06 UTC

This package is auto-updated.

Last update: 2024-05-17 02:05:25 UTC


README

Total Downloads Latest Stable Version License

Filesize

Install

composer require davidvandertuijn/filesize

Usage

use Davidvandertuijn\Filesize;
Filesize::toHumanFriendly(
    1024000, // Bytes
    'kB', // Force Unit
    '%01.2f %s', // Format
    'SI' // Standard
);

SI standard (1000 bytes in a kilobyte)

Filesize::toHumanFriendly(1024000); // 1.02 MB

Force Unit

Filesize::toHumanFriendly(1024000, 'kB'); // 1024.00 kB

Format

Filesize::toHumanFriendly(1024000, null, '%01.3f %s'); // 1.024 MB

IEC standard (1024 bytes in a kibibyte)

Filesize::toHumanFriendly(1048576, null, null, 'IEC'); // 1.00 MiB