format_size($size)
drupal-5/includes/common.inc, line 1003
Generate a string representation for the given byte count.
$size The size in bytes.
A translated string representation of the size.
| Name | Description |
|---|---|
| Formatting | Functions to format numbers, strings, dates, etc. |
| Input validation | Functions to validate user input. |
<?php
function format_size($size) {
if ($size < 1024) {
return format_plural($size, '1 byte', '@count bytes');
}
else {
$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));
}
}
?>