Add default space in byte string format, only read enable ea data

read only enabled edit access data fields
add default space between the converted byte data and the label
This commit is contained in:
Clemens Schwaighofer
2016-08-02 14:38:23 +09:00
parent 20b134231e
commit 31bef7a531
2 changed files with 4 additions and 4 deletions

View File

@@ -1049,17 +1049,17 @@
}
// METHOD: ByteStringFormat
// PARAMS: int
// PARAMS: int bytes, boolean for space, default is set
// RETURN: string
// DESC: converts bytes into formated string with KB, MB, etc
public static function ByteStringFormat($number)
public static function ByteStringFormat($number, $space = true)
{
if (is_numeric($number) && $number > 0)
{
// labels in order of size
$labels = array('B', 'KB', 'MB', 'GB', 'TB');
// calc file size, round down too two digits, add label based max change
return round($number / pow(1024, ($i = floor(log($number, 1024)))), 2).''.$labels[$i];
return round($number / pow(1024, ($i = floor(log($number, 1024)))), 2).($space ? ' ' : '').$labels[$i];
}
return $number;
}