How PHP displays file sizes in a format suitable for reading
This article mainly shows you "PHP how to display file size in a format suitable for reading", which is easy to understand and well organized. I hope it can help you solve your doubts. Let me lead you to study and learn "PHP how to display file size in a format suitable for reading".
The specific analysis is as follows:
File size display, such as 1.7K, 2.9m
The code is as follows:
/ / A much better and accurate version can be found// in Aidan's PHP Repository: / / http://aidanlister.com/repos/v/function.size_readable.php/** * Returns a human readable filesize * * @ author wesman20 (php.net) * @ author Jonas John * @ version 0.3 * @ link http://www.jonasjohn.de/snippets/php/readable-filesize.htm * / function HumanReadableFilesize ($size) { / / Adapted from: http://www.php.net/manual/en/function.filesize.php $mod = 1024 $units = explode (','B KB MB GB TB PB'); for ($I = 0; $size > $mod; $iTunes +) {$size / = $mod;} return round ($size, 2). ''. $units [$I];} above is all the content of the article "how PHP displays file size in a format suitable for reading". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!