| Versions | |
|---|---|
| 4.7 – 5 | format_size($size) |
| 6 – 7 | format_size($size, $langcode = NULL) |
Generate a string representation for the given byte count.
$size The size in bytes.
A translated string representation of the size.
includes/
<?php
function format_size($size) {
$suffix = t('bytes');
if ($size >= 1024) {
$size = round($size / 1024, 2);
$suffix = t('KB');
}
if ($size >= 1024) {
$size = round($size / 1024, 2);
$suffix = t('MB');
}
return t('%size %suffix', array('%size' => $size, '%suffix' => $suffix));
}
?>