Created
December 30, 2009 21:51
-
-
Save ollym/266431 to your computer and use it in GitHub Desktop.
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
public static function memory($bytes, $places = 2) | |
{ | |
static $suffexes = array( | |
'B', 'KB', 'MB', 'GB', 'TB', 'PB' | |
); | |
$i = 0; | |
while ($bytes > 10) | |
{ | |
$bytes /= 1024; | |
$i++; | |
if ( ! isset($suffexes[$i])) | |
{ | |
break; | |
} | |
} | |
return round($bytes, $places).$suffexes[$i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment