file size (M, K, G, T) to bytes (PHP)

function bytes($s) { $units = ‘KMGT’; return pow(1024, strpos($units, strpbrk($s, $units)) + 1) * (int) $s; }   // usage: echo bytes(‘1K’); // 1024 echo bytes(‘1M’); // 1048576function bytes($s) { $units = ‘KMGT’; return pow(1024, strpos($units, strpbrk($s, $units)) + 1) * (int) $s; } // usage: echo bytes(‘1K’); // 1024 echo bytes(‘1M’); // 1048576