public static function humanSize($bytes)
    {
        // Make sure we can't divide by zero
        if ($bytes == 0) {
            return '0 B';
        }

        $value = floor(log($bytes, 1024));

        $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
        $unit = $units[$value]; // Chosen unit

        return sprintf('%.02F', $bytes / pow(1024, $value)) * 1 . ' ' . $unit;
    }
public static function humanSize($bytes)
    {
        // Make sure we can't divide by zero
        if ($bytes == 0) {
            return '0 B';
        }

        $value = floor(log($bytes, 1024));

        $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
        $unit = $units[$value]; // Chosen unit

        return sprintf('%.02F', $bytes / pow(1024, $value)) * 1 . ' ' . $unit;
    }
public static function humanSize ( $ bytes ) { // Make sure we can't divide by zero if ( $ bytes == 0 ) { return '0 B' ; } $ value = floor ( log ( $ bytes , 1024 ) ) ; $ units = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ) ; $ unit = $ units [ $ value ] ; // Chosen unit return sprintf ( '%.02F' , $ bytes / pow ( 1024 , $ value ) ) * 1 . ' ' . $ unit ; }
Turns raw bytes into human-readable format

@param int $bytes
@return string
Turns raw bytes into human - readable format