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