<?php
/**
* @author: Jörg Reinholz, fastix WebDesign & Consult, Kassel - http://www.fastix.org/
* @return string Rounded human readable Integers (E ~ exbi ... G ~ gibi ... K ~ kibi)
* @param string $s will be a float
* @param integer $p - decimals in return, Default: 2
* @param string $e - A String given back after eg. the "B" in KB, default: B
* @param string $t - Separate between number and multiplicator, default ' ''
**/
function humanReadableBin ($s, $p=2, $e='B', $t=' ') {
if ($f >= 1152921504606846976) {
return ( round( ( $f / 1152921504606846976 ) , $p) . $t . 'E' . $e );
} elseif ($f >= 1125899906842624) {
return ( round( ( $f / 1125899906842624 ) , $p) . $t . 'P' . $e );
} elseif ($f >= 1099511627776) {
return ( round( ( $f / 1099511627776 ) , $p) . $t . 'T' . $e );
} elseif ($f >= 1073741824) {
return ( round( ($f / 1073741824 ) , $p) . $t . 'G' . $e );
} elseif ($f >= 1048576) {
return ( round( ( $f / 1048576 ) , $p) . $t . 'M' . $e );
} elseif ($f >= 1024) {
return (round( ( $f / 1024 ) , $p) . $t . 'K' . $e );
} else {
return $f . $t . $e;
}
}