I need to test the value returned by ini_get(\'memory_limit\')
and increase the memory limit if it is below a certain threshold, however this ini_get(\'me
I can only think of a slight variation on what you're doing:
function int_from_bytestring($byteString) {
$ret = 0;
if (preg_match('!^\s*(\d+(?:\.\d+))\s*([KMNGTPE])B?\s*$!', $byteString, $matches)) {
$suffix = " KMGTPE";
$index = strpos($suffix, $matches[2]);
if ($index !== false) {
$ret = $matches[1];
while ($index--) {
$matches *= 1024;
}
}
}
return intval($ret);
}