Skip to content

Instantly share code, notes, and snippets.

@egulhan
Created April 17, 2014 11:47
Show Gist options
  • Save egulhan/10976916 to your computer and use it in GitHub Desktop.
Save egulhan/10976916 to your computer and use it in GitHub Desktop.
Convert bytes to up-sizes
/**
* @source: http://codeaid.net/php/convert-size-in-bytes-to-a-human-readable-format-(php)
*/
function bytesToSize1024($bytes, $precision = 2)
{
$unit = array('B','KB','MB','GB','TB','PB','EB');
return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision).' '.$unit[$i];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment