当前位置 : 主页 > 网络编程 > PHP >

可读性文件尺寸

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt /** * 返回可读性更好的文件尺寸 */function human_filesize($bytes, $decimals = 2){ $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB']; $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$decimals}f", $bytes / pow
gistfile1.txt
/**
 * 返回可读性更好的文件尺寸
 */
function human_filesize($bytes, $decimals = 2)
{
    $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB'];
    $factor = floor((strlen($bytes) - 1) / 3);

    return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) .@$size[$factor];
}
上一篇:对象
下一篇:时间戳转时间格式,防0day
网友评论