Skip to content

Instantly share code, notes, and snippets.

@vukicevic
Created October 21, 2014 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vukicevic/5ec5f0bdad58f5d05fa1 to your computer and use it in GitHub Desktop.
Save vukicevic/5ec5f0bdad58f5d05fa1 to your computer and use it in GitHub Desktop.
Human-readable file size from bytes.
function readable($size, $unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PB')) {
return ($size > 1024) ? readable($size/1024, array_slice($unit, 1)) : round($size, 2) . ' ' . array_shift($unit);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment