new function to convert human readable mememory to bytes

This commit is contained in:
Diego Najar 2019-04-23 23:17:27 +02:00
parent 20b672cd09
commit 8d06d47318

View File

@ -297,4 +297,10 @@ class Text {
return $truncate;
}
public static function toBytes($value) {
$value = trim($value);
$s = [ 'g'=> 1<<30, 'm' => 1<<20, 'k' => 1<<10 ];
return intval($value) * ($s[strtolower(substr($value,-1))] ?: 1);
}
}