src/DataHandling.php
public static function formatBytesize($size)
    {
        $suffixes = [
            "B", "KiB", "MiB", "GiB", "TiB" //, "PiB", "EiB", "ZiB", "YiB"
        ];

        $level = 1;
        for ($exponent = 0; $exponent < count($suffixes); $exponent++) {
            $nextLevel = pow(1024, $exponent + 1);

            if ($nextLevel > $size) {
                $smallSize = $size / $level;

                if ($smallSize < 10) {
                    $decimals = 2;
                } elseif ($smallSize < 100) {
                    $decimals = 1;
                } else {
                    $decimals = 0;
                }

                return round($smallSize, $decimals) . " " . $suffixes[$exponent];
            }

            $level = $nextLevel;
        }

        return "Large.";
    }
public static function formatBytesize($size)
    {
        $suffixes = [
            "B", "KiB", "MiB", "GiB", "TiB" //, "PiB", "EiB", "ZiB", "YiB"
        ];

        $level = 1;
        for ($exponent = 0; $exponent < count($suffixes); $exponent++) {
            $nextLevel = pow(1024, $exponent + 1);

            if ($nextLevel > $size) {
                $smallSize = $size / $level;

                if ($smallSize < 10) {
                    $decimals = 2;
                } elseif ($smallSize < 100) {
                    $decimals = 1;
                } else {
                    $decimals = 0;
                }

                return round($smallSize, $decimals) . " " . $suffixes[$exponent];
            }

            $level = $nextLevel;
        }

        return "Large.";
    }
public static function formatBytesize ( $ size ) { $ suffixes = [ "B" , "KiB" , "MiB" , "GiB" , "TiB" //, "PiB", "EiB", "ZiB", "YiB" ] ; $ level = 1 ; for ( $ exponent = 0 ; $ exponent < count ( $ suffixes ) ; $ exponent ++ ) { $ nextLevel = pow ( 1024 , $ exponent + 1 ) ; if ( $ nextLevel > $ size ) { $ smallSize = $ size / $ level ; if ( $ smallSize < 10 ) { $ decimals = 2 ; } elseif ( $ smallSize < 100 ) { $ decimals = 1 ; } else { $ decimals = 0 ; } return round ( $ smallSize , $ decimals ) . " " . $ suffixes [ $ exponent ] ; } $ level = $ nextLevel ; } return "Large." ; }
Returns a suffixed and shortened indication of an amount of bytes.

@param int $size
@return string
Returns a suffixed and shortened indication of an amount of bytes .