summaryrefslogtreecommitdiffstats
path: root/application/helpers/filebin_helper.php
blob: 4063fd3fb02168218eb8e48d287e3bc5672af838 (plain)
1
2
3
4
5
6
7
8
9
10
<?php

// Source: http://ibnuyahya.com/format-bytes-to-kb-mb-gb/
function format_bytes($size, $precision = 2){
		$base = log($size) / log(1024);
		$suffixes = array('B', 'KiB', 'MiB', 'GiB', 'TiB' , 'PiB' , 'EiB');
		return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
}

# vim: set noet: