From 8d06d47318bd65cf92b3015757f9615344e0b20d Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Tue, 23 Apr 2019 23:17:27 +0200 Subject: [PATCH] new function to convert human readable mememory to bytes --- bl-kernel/helpers/text.class.php | 6 ++++++ 1 file changed, 6 insertions(+) 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); + } + }