src/Suki/Tools.php
public function formatBytes($bytes, $showUnits = false, $log = 1024): string
	{
		$units = array('B', 'KB', 'MB', 'GB', 'TB');
		$bytes = max($bytes, 0);
		$pow = floor(($bytes ? log($bytes) : 0) / log($log));
		$pow = min($pow, count($units) - 1);
		$bytes /= (1 << (10 * $pow));

		return round($bytes, 2) . ($showUnits ? ' ' . $units[$pow] : '');
	}
public function formatBytes($bytes, $showUnits = false, $log = 1024): string
	{
		$units = array('B', 'KB', 'MB', 'GB', 'TB');
		$bytes = max($bytes, 0);
		$pow = floor(($bytes ? log($bytes) : 0) / log($log));
		$pow = min($pow, count($units) - 1);
		$bytes /= (1 << (10 * $pow));

		return round($bytes, 2) . ($showUnits ? ' ' . $units[$pow] : '');
	}
public function formatBytes ( $ bytes , $ showUnits = false , $ log = 1024 ) : string { $ units = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TB' ) ; $ bytes = max ( $ bytes , 0 ) ; $ pow = floor ( ( $ bytes ? log ( $ bytes ) : 0 ) / log ( $ log ) ) ; $ pow = min ( $ pow , count ( $ units ) - 1 ) ; $ bytes /= ( 1 << ( 10 * $ pow ) ) ; return round ( $ bytes , 2 ) . ( $ showUnits ? ' ' . $ units [ $ pow ] : '' ) ; }
Returns a formatted string.
@access public
@param string|int  $bytes A number of bytes.
@param bool $showUnits To show the unit symbol or not.
@param int  $log the log used, either 1024 or 1000.
@return string
Returns a formatted string .