letraceursnork/format-bytes

Simple function formatBytes() that you all heard about and implemented - now in packagist

v1.0.0 2024-11-01 09:31 UTC

This package is auto-updated.

Last update: 2025-06-14 06:22:28 UTC


README

Simple function formatBytes() that you all heard about and implemented - now in packagist

Installation

Composer installation:

composer require letraceursnork/format-bytes

Usage

use LTS\FormatBytes\Formatter;

$formatter = new Formatter();
$formatter = new Formatter([' bytes suffix', ' KBytes suffix', ' MBytes suffix', 'etc...']);
$bytes = 2048;
$result = $formatter->formatBytes($bytes, $optional_precision);
echo $result; // 2 KBytes suffix