Implementation code for php formatted file size

WBOY
Release: 2016-07-25 08:59:49
Original
866 people have browsed it
This article introduces a PHP code that implements formatted file size. The so-called formatted file size means that the file size in bytes is displayed in an easy-to-read manner, such as 120GB, 30MB, etc.

The code is as follows:

<?php
/**
* 格式化文件大小
* Edit bbs.it-home.org
*/
function format($size)
{
$sizetext = array(" B", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
return round($size/pow(1024,($i=floor(log($size,1024)))),2).$sizetext[$i];
}
?>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!