<?php
	# All about file include/func.inc.php (/usr/share/zabbix)
	# in package zabbix-frontend-php (apt show...) v3.0.7

	# region Your implementation is so bad.
	/**
	 * Converts strings like 2M or 5k to bytes
	 *
	 * @param string $val
	 *
	 * @return int
	 */
	function str2mem($val) {
		$val = trim($val);
		$last = strtolower(substr($val, -1));

		switch ($last) {
			case 'g':
				$val *= 1024;
				/* falls through */
			case 'm':
				$val *= 1024;
				/* falls through */
			case 'k':
				$val *= 1024;
		}

		return $val;
	}

	#endregion


	# region But you see to next code
	define('STR2MEM_UNITS', [
        'k' => 1024,
        'm' => 1048576,
        'g' => 1073741824,
        't' => 1099511627776
	]);

	/**
	 * Converts strings like 2M or 5k to bytes
	 *
	 * @param string $val
	 *
	 * @return int
	 */
	function str2mem($val) {
	        $val = trim($val);
	        $unit = strtolower(substr($val, -1));

	        if (in_array($unit, array_keys(STR2MEM_UNITS))) {
	                return substr($val, 0, -1) * STR2MEM_UNITS[$unit];
	        }

	        return $val;
	}

	# endregion

	# Best regards