1/**
 2 * @author MRASONG
 3 * @param  int    $number      The number being formatted
 4 * @param  int    $decimals    Sets the number of decimal points.
 5 * @param  string $format      The format string [sprintf]
 6 * @return string
 7 */
 8public static function fsize($number=0, $decimals=2, $format='%s %s'){
 9    $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
10    $i = 0;
11    $base = pow(2, 10);
12    $size = $number;
13    while ($number >= pow($base, $i+1)) {
14        $size = $number / pow($base, ++$i);
15    }
16    return sprintf($format, number_format($size, $decimals, '.', ''), $units[$i]);
17}