Fixed returnBytes function return correct amount of bytes

pull/10/merge
thomasmars 2017-05-29 11:18:12 +02:00
parent 0ce7d66c3a
commit fa31c56dce
1 changed files with 7 additions and 5 deletions

View File

@ -2969,18 +2969,20 @@ class H5PCore {
* @return int|string * @return int|string
*/ */
public static function returnBytes($val) { public static function returnBytes($val) {
$val = (int) trim($val); $val = trim($val);
$last = strtolower($val[strlen($val) - 1]); $last = strtolower($val[strlen($val) - 1]);
$bytes = (int) $val;
switch ($last) { switch ($last) {
case 'g': case 'g':
$val *= 1024; $bytes *= 1024;
case 'm': case 'm':
$val *= 1024; $bytes *= 1024;
case 'k': case 'k':
$val *= 1024; $bytes *= 1024;
} }
return $val; return $bytes;
} }
/** /**