public static function bytes($bytes)
  {
    $kbytes = sprintf("%.02f", $bytes/1024);
    $mbytes = sprintf("%.02f", $kbytes/1024);
    $gbytes = sprintf("%.02f", $mbytes/1024);
    $tbytes = sprintf("%.02f", $gbytes/1024);

    if($tbytes >= 1)
      return $tbytes . " TB";
    if($gbytes >= 1)
      return $gbytes . " GB";
    if($mbytes >= 1)
      return $mbytes . " MB";
    if($kbytes >= 1)
      return $kbytes . " KB";

    return $bytes . " B";
  }
public static function bytes($bytes)
  {
    $kbytes = sprintf("%.02f", $bytes/1024);
    $mbytes = sprintf("%.02f", $kbytes/1024);
    $gbytes = sprintf("%.02f", $mbytes/1024);
    $tbytes = sprintf("%.02f", $gbytes/1024);

    if($tbytes >= 1)
      return $tbytes . " TB";
    if($gbytes >= 1)
      return $gbytes . " GB";
    if($mbytes >= 1)
      return $mbytes . " MB";
    if($kbytes >= 1)
      return $kbytes . " KB";

    return $bytes . " B";
  }
public static function bytes ( $ bytes ) { $ kbytes = sprintf ( "%.02f" , $ bytes / 1024 ) ; $ mbytes = sprintf ( "%.02f" , $ kbytes / 1024 ) ; $ gbytes = sprintf ( "%.02f" , $ mbytes / 1024 ) ; $ tbytes = sprintf ( "%.02f" , $ gbytes / 1024 ) ; if ( $ tbytes >= 1 ) return $ tbytes . " TB" ; if ( $ gbytes >= 1 ) return $ gbytes . " GB" ; if ( $ mbytes >= 1 ) return $ mbytes . " MB" ; if ( $ kbytes >= 1 ) return $ kbytes . " KB" ; return $ bytes . " B" ; }
Converts bytes to a human readable value.

@param  integer $bytes
@return string
Converts bytes to a human readable value .