summaryrefslogtreecommitdiffstats
path: root/system/application/helpers/filebin_helper.php
blob: 34b231023a6661666ec67bae311436edbcc65693 (plain)
1
2
3
4
5
6
7
8
9
<?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', 'kB', 'MB', 'GB', 'TB' , 'PB' , 'EB');
    return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
}