blob: 3d6c30b76edaa0a72d80e355324f1ea80fac2c52 (
plain)
1
2
3
4
5
6
7
8
9
10
|
<?php
// Source: http://ibnuyahya.com/format-bytes-to-kb-mb-gb/
function format_bytes($size, $precision = 2){
$base = log($size) / log(1024);
$suffixes = array('B', 'kB', 'MB', 'GB', 'TB' , 'PB' , 'EB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
}
# vim: set noet:
|