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]; }
Output for 8.5.0 - 8.5.3
Deprecated: Non-canonical cast (double) is deprecated, use the (float) cast instead in /in/dOQkX on line 9 10B 100B 0.98kB 9.77kB 97.66kB 0.95MB 9.54MB 95.37MB 0.93GB 9.31GB 93.13GB 0.91TB 9.09TB 90.95TB 909.49TB 8.88PB 88.82PB 888.18PB 8.67EB 86.74EB 867.36EB 8.47ZB 84.7ZB 847.03ZB 8.27YB 82.72YB
Output for 5.6.38, 7.1.0 - 7.1.24, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18
10B 100B 0.98kB 9.77kB 97.66kB 0.95MB 9.54MB 95.37MB 0.93GB 9.31GB 93.13GB 0.91TB 9.09TB 90.95TB 909.49TB 8.88PB 88.82PB 888.18PB 8.67EB 86.74EB 867.36EB 8.47ZB 84.7ZB 847.03ZB 8.27YB 82.72YB

preferences:
108.02 ms | 1493 KiB | 4 Q