This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)

@param string $sSize
@return integer The value in bytes
338623
public static function convertPHPSizeToBytes($sSize)
    {
        //
        $sSuffix = strtoupper(substr($sSize, -1));
        if (!in_array($sSuffix, array('P', 'T', 'G', 'M', 'K'))) {
            return (int) $sSize;
        }
        $iValue = substr($sSize, 0, -1);
        switch ($sSuffix) {
            case 'P':
                $iValue *= 1024;
            // Fallthrough intended
            case 'T':
                $iValue *= 1024;
            // Fallthrough intended
            case 'G':
                $iValue *= 1024;
            // Fallthrough intended
            case 'M':
                $iValue *= 1024;
            // Fallthrough intended
            case 'K':
                $iValue *= 1024;
                break;
        }
        return (int) $iValue;
    }
1192251
public static function formatSize($size, $decimalPrecision = 2) {

        if ($size < 1024)                           return $size . ' B';
        elseif ($size < 1048576)                   return round($size / 1024, $decimalPrecision) . ' kB';
        elseif ($size < 1073741824)                return round($size / 1048576, $decimalPrecision) . ' MB';
        elseif ($size < 1099511627776)             return round($size / 1073741824, $decimalPrecision) . ' GB';
        elseif ($size < 1125899906842624)          return round($size / 1099511627776, $decimalPrecision) . ' TB';
        elseif ($size < 1152921504606846976)       return round($size / 1125899906842624, $decimalPrecision) . ' PB';
        else return round($size / 1152921504606846976, $decimalPrecision) . ' EB';
    }
568398
public static function GetPhpIniSizeLimit ($iniVarName) {
		$rawIniValue = @ini_get($iniVarName);
		if ($rawIniValue === FALSE) {
			return 0;
		} else if ($rawIniValue === NULL) {
			return NULL;
		}
		$unit = strtoupper(substr($rawIniValue, -1));
		$multiplier = (
			$unit == 'M' 
				? 1048576 
				: ($unit == 'K' 
					? 1024 
					: ($unit == 'G' 
						? 1073741824 
						: 1)));
		return intval($multiplier * floatval($rawIniValue));
	}
313064
protected function int2letter($int)
    {
        $lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $size = strlen($lookup);

        $letters = '';
        while ($int > 0) {
            $int--;
            $letters = $lookup[$int % $size] . $letters;
            $int = floor($int / $size);
        }
        return $letters;
    }
696460
protected function getByteSize($size)
    {
        if (! preg_match('/(\d+)\s*([tgkmbi]{1,3})/i', $size, $result)) {
            return $size;
        }

        $mapping = $this->mapping[strtolower($result[2])];
        return pow($mapping[0], $mapping[1]) * $result[1];
    }
1345654
public static function convertToBytes(string $size = null) : float
    {
        // Prepare the size
        $size = trim((string) $size);

        // Construct an OR list of byte units for the regex
        $accepted = implode('|', array_keys(Number::$byte_units));

        // Construct the regex pattern for verifying the size format
        $pattern = '/^([0-9]+(?:\.[0-9]+)?)('.$accepted.')?$/Di';

        // Verify the size format and store the matching parts
        if (!preg_match($pattern, $size, $matches)) {
            throw new \RuntimeException('The byte unit size, "'.$size.'", is improperly formatted.');
        }

        // Find the float value of the size
        $size = (float) $matches[1];

        // Find the actual unit, assume B if no unit specified
        $unit = Arr::get($matches, 2, 'B');

        // Convert the size into bytes
        $bytes = $size * pow(2, Number::$byte_units[$unit]);

        return $bytes;
    }
843990
private function convertShorthandSize($size)
    {
        // Initialize
        $size = trim($size);
        $unit = '';

        // Check unlimited alias
        if ($size === '-1') {
            return \INF;
        }

        // Check size
        if (!ctype_digit($size)) {
            $unit = strtolower(substr($size, -1, 1));
            $size = (int) substr($size, 0, -1);
        }

        // Return converted size
        switch ($unit) {
            case 'g':
                return $size * 1024 * 1024 * 1024;
            case 'm':
                return $size * 1024 * 1024;
            case 'k':
                return $size * 1024;
            default:
                return (int) $size;
        }
    }
697459
public static function formatFileSize($size) {
        if ( $size/1024 < 1 ) {
            return $size ." B";
        } else if ( $size/1024 > 1 && $size/(1024*1024) < 1 ) {
            return number_format($size/1024, 2, '.', '') .'KB';
        } else if ( $size/(1024*1024) > 1 && $size/(1024*1024*1024)< 1 ) {
            return number_format($size/(1024*1024), 2, '.', '') ." MB";
        } else {
            return number_format($size/(1024*1024*1024), 2, '.', '')." GB";
        }
    }
1051228
public static function toInt(string $str) : int
    {
        $result = 0;
        $str    = mb_convert_kana(self::replaceRoman($str), 'a');
        foreach (self::$romans as $key => $value) {
            while (mb_strpos($str, $key) === 0) {
                $result += $value;
                $str = mb_substr($str, strlen($key));
            }
        }
        return $result;
    }
1260710
public static function bytesSizeInt($int)
    {
        $nbytes = 0;

        if ($int > 0xE) {
            $nbytes += 2; // 2 size-bytes
        }
        if ($int > 0xFF) {
            $nbytes += 1; // 3 size-bytes
        }
        if ($int > 0xFFFF) {
            $nbytes += 2; // 5 size-bytes
        }

        return $nbytes;
    }
1136599
public static function formatIniParamSize(string $res): int
    {
        $res = trim($res);
        $measure = strtolower($res[strlen($res) - 1]);
        $res = (int)$res;

        // No breaks in switch, because we need multiple calculations
        switch ($measure) {
            /** @noinspection PhpMissingBreakStatementInspection */
            case 'g':
                $res *= 1024;
            /** @noinspection PhpMissingBreakStatementInspection */
            case 'm':
                $res *= 1024;
            case 'k':
                $res *= 1024;
        }

        return $res;
    }
387996
protected function asc2int($asc): int
    {
        return (ord($asc[0]) << 24) | (ord($asc[1]) << 16) |
            (ord($asc[2]) << 8) | (ord($asc[3]));
    }
692276
public static function intBytes($int)
    {
        $intbytes = "";

        if ($int > 0xFFFF) {
            $intbytes = "\x12".pack("N", $int); // 4 byte integer
        } elseif ($int > 0xFF) {
            $intbytes = "\x11".pack("n", $int); // 2 byte integer
        } else {
            $intbytes = "\x10".pack("C", $int); // 8 byte integer
        }

        return $intbytes;
    }
1102686
function getsize($size)
    {
        $last = strtolower($size{strlen($size) - 1});
        switch ($last) {
            case 'g':
                $size *= 1024;
            case 'm':
                $size *= 1024;
            case 'k':
                $size *= 1024;
        }

        return $size;
    }
1049864
protected function _toByteString($size)
    {
        $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
        for ($i=0; $size >= 1024 && $i < 9; $i++) {
            $size /= 1024;
        }

        return round($size, 2) . $sizes[$i];
    }
687561
protected function getSize($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        if (is_array($value) || $value instanceof Countable) {
            return count($value);
        }

        return mb_strlen($value);
    }
623181
public static function sizeInBytes($value)
    {
        $value = trim($value);
        $last = strtolower($value[strlen($value)-1]);

        switch($last) {
            case 'g':
                $value *= 1024;
            case 'm':
                $value *= 1024;
            case 'k':
                $value *= 1024;
        }

        return (int) $value;
    }