Returns the size of a file using binary prefixes when given the file size in bytes.
<?php
// fs(size) returns formatted file size string
function fs($fs) {
$sizes = array('B','KiB','MiB','GiB','TiB');
$ex = substr(floor(log($fs)/log(2)),0,-1);
$v = round($fs / pow(2,$ex * 10),2);
return $v . $sizes[($ex ? $ex : 0)];
}
?>