parse_size

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/common.inc, строка 1178

Версии
5 – 6
parse_size($size)

Parse a given byte count.

Параметры

$size A size expressed as a number of bytes with optional SI size and unit suffix (e.g. 2, 3K, 5MB, 10G).

Возвращаемое значение

An integer representation of the size.

Связанные темы

▾ 3 функции вызывают parse_size()

color_scheme_form_submit in modules/color/color.module
Submit handler for color change form.
file_upload_max_size in includes/file.inc
Определяет максимальный размер загружаемого файла из настроек PHP.
system_requirements in modules/system/system.install
Test and report Drupal installation requirements.

Код

<?php
function parse_size($size) {
  $suffixes = array(
    '' => 1,
    'k' => 1024,
    'm' => 1048576, // 1024 * 1024
    'g' => 1073741824, // 1024 * 1024 * 1024
  );
  if (preg_match('/([0-9]+)\s*(k|m|g)?(b?(ytes?)?)/i', $size, $match)) {
    return $match[1] * $suffixes[drupal_strtolower($match[2])];
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему