roundcubemail/program/include/rcmail.php
public function show_bytes($bytes, &$unit = null)
    {
        if ($bytes >= 1073741824) {
            $unit = 'GB';
            $gb   = $bytes/1073741824;
            $str  = sprintf($gb >= 10 ? "%d " : "%.1f ", $gb) . $this->gettext($unit);
        }
        else if ($bytes >= 1048576) {
            $unit = 'MB';
            $mb   = $bytes/1048576;
            $str  = sprintf($mb >= 10 ? "%d " : "%.1f ", $mb) . $this->gettext($unit);
        }
        else if ($bytes >= 1024) {
            $unit = 'KB';
            $str  = sprintf("%d ",  round($bytes/1024)) . $this->gettext($unit);
        }
        else {
            $unit = 'B';
            $str  = sprintf('%d ', $bytes) . $this->gettext($unit);
        }

        return $str;
    }
public function show_bytes($bytes, &$unit = null)
    {
        if ($bytes >= 1073741824) {
            $unit = 'GB';
            $gb   = $bytes/1073741824;
            $str  = sprintf($gb >= 10 ? "%d " : "%.1f ", $gb) . $this->gettext($unit);
        }
        else if ($bytes >= 1048576) {
            $unit = 'MB';
            $mb   = $bytes/1048576;
            $str  = sprintf($mb >= 10 ? "%d " : "%.1f ", $mb) . $this->gettext($unit);
        }
        else if ($bytes >= 1024) {
            $unit = 'KB';
            $str  = sprintf("%d ",  round($bytes/1024)) . $this->gettext($unit);
        }
        else {
            $unit = 'B';
            $str  = sprintf('%d ', $bytes) . $this->gettext($unit);
        }

        return $str;
    }
public function show_bytes ( $ bytes , & $ unit = null ) { if ( $ bytes >= 1073741824 ) { $ unit = 'GB' ; $ gb = $ bytes / 1073741824 ; $ str = sprintf ( $ gb >= 10 ? "%d " : "%.1f " , $ gb ) . $ this -> gettext ( $ unit ) ; } else if ( $ bytes >= 1048576 ) { $ unit = 'MB' ; $ mb = $ bytes / 1048576 ; $ str = sprintf ( $ mb >= 10 ? "%d " : "%.1f " , $ mb ) . $ this -> gettext ( $ unit ) ; } else if ( $ bytes >= 1024 ) { $ unit = 'KB' ; $ str = sprintf ( "%d " , round ( $ bytes / 1024 ) ) . $ this -> gettext ( $ unit ) ; } else { $ unit = 'B' ; $ str = sprintf ( '%d ' , $ bytes ) . $ this -> gettext ( $ unit ) ; } return $ str ; }
Create a human readable string for a number of bytes

@param int    $bytes Number of bytes
@param string &$unit Size unit

@return string Byte string
Create a human readable string for a number of bytes