Here Is A Simple Function To Convert Bytes To Kb

[Solved] Here Is A Simple Function To Convert Bytes To Kb | Vb - Code Explorer | yomemimo.com
Question : Here is a simple function to convert Bytes to KB, MB, GB, TB :

Answered by : cleophas-o

<?php
// Snippet from PHP Share: http://www.phpshare.org function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes == 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes;
}
?>

Source : https://stackoverflow.com/questions/5501427/php-filesize-mb-kb-conversion/11860664 | Last Update : Thu, 10 Feb 22

Answers related to here is a simple function to convert bytes to kb mb gb tb

Code Explorer Popular Question For Vb