Created
March 20, 2012 01:41
-
-
Save clone1018/2129743 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
<?php | |
function humanReadableOctets($octets) { | |
$units = array('B', 'kB', 'MB', 'GB', 'TB'); | |
for ($i = 0, $size =$octets; $size>1024; $size=$size/1024) | |
$i++; | |
return number_format($size, 2) . ' ' . $units[min($i, count($units) -1 )]; | |
} | |
echo humanReadableOctets(1000000000000999); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment