#native_company# #native_desc#
#native_cta#

GetSize

By Ben Summers
on November 5, 2001

Version: 1.0

Type: Function

Category: File Management

License: GNU General Public License

Description: pass the number of bytes and it automatically returns it in b,kb,mb,gb,tb or pb

function GetSize ($sizeb) {
  $sizekb = $sizeb / 1024;
  $sizemb = $sizekb / 1024;
  $sizegb = $sizemb / 1024;
  $sizetb = $sizegb / 1024;
  $sizepb = $sizetb / 1024;
  if ($sizeb > 1) {$size = round($sizeb,2) . "b";}
  if ($sizekb > 1) {$size = round($sizekb,2) . "kb";}
  if ($sizemb > 1) {$size = round($sizemb,2) . "mb";}
  if ($sizegb > 1) {$size = round($sizegb,2) . "gb";}
  if ($sizetb > 1) {$size = round($sizetb,2) . "tb";}
  if ($sizepb > 1) {$size = round($sizepb,2) . "pb";}
  return $size;
}