mirror of
https://github.com/friendica/friendica
synced 2024-11-10 04:22:54 +00:00
moved formatBytes() to /include/text.php
This commit is contained in:
parent
a982320ba9
commit
68e565889d
2 changed files with 12 additions and 11 deletions
|
@ -1014,14 +1014,3 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
|
|||
return($image);
|
||||
}
|
||||
|
||||
function formatBytes($bytes, $precision = 2) {
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||
|
||||
$bytes = max($bytes, 0);
|
||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||
$pow = min($pow, count($units) - 1);
|
||||
|
||||
$bytes /= pow(1024, $pow);
|
||||
|
||||
return round($bytes, $precision) . ' ' . $units[$pow];
|
||||
}
|
||||
|
|
|
@ -2282,3 +2282,15 @@ function deindent($text, $chr="[\t ]", $count=NULL) {
|
|||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
function formatBytes($bytes, $precision = 2) {
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||
|
||||
$bytes = max($bytes, 0);
|
||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||
$pow = min($pow, count($units) - 1);
|
||||
|
||||
$bytes /= pow(1024, $pow);
|
||||
|
||||
return round($bytes, $precision) . ' ' . $units[$pow];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue