Created
April 17, 2014 11:47
-
-
Save egulhan/10976916 to your computer and use it in GitHub Desktop.
Convert bytes to up-sizes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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