/ Published in: PHP
This function converts file size in bytes to the larger units.
You can add bigger values like exa-, zetta-, yotta- bytes.
You can add bigger values like exa-, zetta-, yotta- bytes.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function calculateSize($size, $sep = ' ') { $unit = null; { if ($size > 1024) { $size = $size / 1024; } else { $unit = $units[$i]; break; } } } echo calculateSize(32942443); // Result: 31.42 MB echo calculateSize(2298543567223, ''); // Result: 2.09TB