public static function humanFileSize($size, $unit = '')
    {
        if (self::isHumanFilesizeUnitGb($size, $unit)) {
            return number_format($size / (1 << 30), 2) . 'GB';
        }
        if (self::isHumanFilesizeUnitMb($size, $unit)) {
            return number_format($size / (1 << 20), 2) . 'MB';
        }
        if (self::isHumanFilesizeUnitKb($size, $unit)) {
            return number_format($size / (1 << 10), 2) . 'KB';
        }

        return number_format($size) . ' bytes';
    }
public static function humanFileSize($size, $unit = '')
    {
        if (self::isHumanFilesizeUnitGb($size, $unit)) {
            return number_format($size / (1 << 30), 2) . 'GB';
        }
        if (self::isHumanFilesizeUnitMb($size, $unit)) {
            return number_format($size / (1 << 20), 2) . 'MB';
        }
        if (self::isHumanFilesizeUnitKb($size, $unit)) {
            return number_format($size / (1 << 10), 2) . 'KB';
        }

        return number_format($size) . ' bytes';
    }
public static function humanFileSize ( $ size , $ unit = '' ) { if ( self :: isHumanFilesizeUnitGb ( $ size , $ unit ) ) { return number_format ( $ size / ( 1 << 30 ) , 2 ) . 'GB' ; } if ( self :: isHumanFilesizeUnitMb ( $ size , $ unit ) ) { return number_format ( $ size / ( 1 << 20 ) , 2 ) . 'MB' ; } if ( self :: isHumanFilesizeUnitKb ( $ size , $ unit ) ) { return number_format ( $ size / ( 1 << 10 ) , 2 ) . 'KB' ; } return number_format ( $ size ) . ' bytes' ; }
Converts an amount of bytes to a human readable
format

@param        $size
@param string $unit

@return string
Converts an amount of bytes to a human readable format