PHP code example of ankitjain28may / prettysize

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

    

ankitjain28may / prettysize example snippets


Pretty::pretty($size, $nospace, $one, $places);

/*
  $size : Size in bytes to be converted (Required)
  $nospace : Remove space from the output (Default - false)
  $one : Single character for the size (Default - false)
  $places : Number of decimal places to return (Default - 1)
 */

use Ankitjain28may\Prettysize\Pretty;

$size = Pretty::pretty(1024);
// $size = "1.0 kB"

$size = Pretty::pretty(1024, true, true, 2);
// $size = "1.00k"

$size = Pretty::pretty(1024, ['nospace' => true, 'one' => true, 'places' => 5]);
// $size = "1.00000k"