Home > php教程 > php手册 > body text

分享一个字节大小格式化函数

WBOY
Release: 2016-06-07 11:43:40
Original
1162 people have browsed it

一个超简单的字节格式化函数
/**<br>  * 格式化字节大小<br>  * @param  number $size      字节数<br>  * @param  string $delimiter 数字和单位分隔符<br>  * @return string            格式化后的带单位的大小<br>  * @author 麦当苗儿 <zuojiazi><br>  */<br> function format_bytes($size, $delimiter = '') {<br>     $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');<br>     for ($i = 0; $size >= 1024 && $i      return round($size, 2) . $delimiter . $units[$i];<br> }</zuojiazi>

AD:真正免费,域名+虚机+企业邮箱=0元

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template