code: public static function sizeToBytes($string) {
          $bytes = 0;
          $bytesTable = array(
              'B' => 1,
              'K' => 1024,
              'KB' => 1024,
              'M' => 1024 * 1024,
              'MB' => 1024 * 1024,
              'G' => 1024 * 1024 * 1024,
              'T' => 1024 * 1024 * 1024 * 1024,
              'P' => 1024 * 1024 * 1024 * 1024 * 1024,
          );
  
          preg_match('/(\d+)(\w+)/', $string, $units);
          $unit   = strtoupper($units[2]);
          $bytes  = floatval($units[1]);
          if (array_key_exists($unit, $bytesTable)) {
              $bytes *= $bytesTable[$unit];
          }
  
          $bytes = intval(round($bytes, 2));
  
          return $bytes;
      }
docs: Converts human readable file size (e.g. 10 MB, 200.20 GB) into bytes.
  
  @param string $str
  @return int the result is in bytes
  @author Livingstone Fultang <livingstone@budkit.org> modified to include M, K, KiB etc...