| 1 | <?php |
| 2 | |
| 3 | function formatSizeUnits($bytes) |
| 4 | { |
| 5 | if ($bytes >= 1073741824) |
| 6 | { |
| 7 | $bytes = number_format($bytes / 1073741824, 2) . ' GB'; |
| 8 | } |
| 9 | elseif ($bytes >= 1048576) |
| 10 | { |
| 11 | $bytes = number_format($bytes / 1048576, 2) . ' MB'; |
| 12 | } |
| 13 | elseif ($bytes >= 1024) |
| 14 | { |
| 15 | $bytes = number_format($bytes / 1024, 2) . ' KB'; |
| 16 | } |
| 17 | elseif ($bytes > 1) |
| 18 | { |
| 19 | $bytes = $bytes . ' bytes'; |
| 20 | } |
| 21 | elseif ($bytes == 1) |
| 22 | { |
| 23 | $bytes = $bytes . ' byte'; |
| 24 | } |
| 25 | else |
| 26 | { |
| 27 | $bytes = '0 bytes'; |
| 28 | } |
| 29 | |
| 30 | return $bytes; |
| 31 | } |
To add a comment, please login or register first.
Register or Login