diff --git a/bl-kernel/helpers/text.class.php b/bl-kernel/helpers/text.class.php index b7a84176..9f7093ea 100644 --- a/bl-kernel/helpers/text.class.php +++ b/bl-kernel/helpers/text.class.php @@ -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); + } + }