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 |