PHP code example of letraceursnork / format-bytes

1. Go to this page and download the library: Download letraceursnork/format-bytes 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/ */

    

letraceursnork / format-bytes example snippets


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