File size format conversion

WBOY
Release: 2016-07-25 08:47:50
Original
1385 people have browsed it
Convert file bytes B to KB, MB, GB, TB
  1. function format_bytes($size,$r) {
  2. $units = array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB ", "YB");
  3. for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
  4. return round($size,$r).$units [$i];
  5. }
  6. //$r is the number of decimal places
Copy code


Related labels:
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