3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function convertToBytes($from){ $number=substr($from,0,-2); switch(strtoupper(substr($from,-2))){ case "KB": return $number*1024; case "MB": return $number*pow(1024,2); case "GB": return $number*pow(1024,3); case "TB": return $number*pow(1024,4); case "PB": return $number*pow(1024,5); default: return $from; } } echo convertToBytes("2GB"); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2147483648