3v4l.org

run code in 300+ PHP versions simultaneously
<?php for($i = 1; $i < 27; $i++) { $size = pow(10,$i); echo readableBytes($size) . PHP_EOL; } function readableBytes($size, $type='pc') { //ignore the pc - it is for something else - disabled for debugging $size = (double)$size; static $units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); $step = 1024; $i = 0; while (($size / $step) > 0.9) { $size = $size / $step; $i++; } return round($size, 2).$units[$i]; }

preferences:
112.68 ms | 1493 KiB | 5 Q