f::nice_size PHP Method

nice_size() static public method

Converts an integer size into a human readable format
static public nice_size ( integer $size ) : string
$size integer The file size
return string
    static function nice_size($size)
    {
        $size = str::sanitize($size, 'int');
        if ($size < 1) {
            return '0 kb';
        }
        $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
        return @round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[$i];
    }

Usage Example

Example #1
0
 function niceTotalSize()
 {
     return f::nice_size($this->totalSize());
 }
All Usage Examples Of f::nice_size