PHP 字节格式化函数

//------字节格式化--------------------------
function byte_format($size,$dec=2)
{
    $a = array("B","KB","MB","GB","TB","PB","EB","ZB","YB");
    $pos = 0;
    while ($size >= 1024)   
    {
        $size /= 1024;
        $pos++;
    }
    return round($size,$dec)." ".$a[$pos];
}

你可能感兴趣的:(函数,格式化,巧妙的字节)