Files
pathfinder/app/main/lib/format/Number.php
Mark Friedrich 964dd0f7c9 - Enhancement, new admin "cronjob" dashboard on /setup page, closed #871
- Improved `/setup` page, show DB table `charset`/`collation` info
- Upgraded "[_Peity_](http://benpickles.github.io/peity)" js lib `v3.2.1` → `v3.3.0`
2019-10-30 23:12:25 +01:00

24 lines
548 B
PHP

<?php
namespace lib\format;
class Number extends \Prefab {
/**
* convert Bytes to string + suffix
* @param int $bytes
* @param int $precision
* @return string
*/
public function bytesToString($bytes,$precision = 2) : string {
$result = '0';
if($bytes){
$base = log($bytes, 1024);
$suffixes = ['', 'KB', 'M', 'GB', 'TB'];
$result = round(pow(1024, $base - floor($base)), $precision) .''. $suffixes[(int)floor($base)];
}
return $result;
}
}