Skip to content

Instantly share code, notes, and snippets.

@Nolwennig
Created April 21, 2021 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nolwennig/f4d912091eeba3383645f5c96f72aa38 to your computer and use it in GitHub Desktop.
Save Nolwennig/f4d912091eeba3383645f5c96f72aa38 to your computer and use it in GitHub Desktop.
non well formed numeric value
public static function parseSize($size)
{
$strSize = trim($size);
$last = strtolower($strSize[strlen($strSize)-1]);
$size = rtrim($strSize, $last);
switch ($last) {
case 'g': $size *= 1024;
case 'm': $size *= 1024;
case 'k': $size *= 1024;
}
return (float)$size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment