3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fm_get_filesize($size) { $size = (float) $size; $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $power = $size > 0 ? floor(log($size, 1024)) : 0; return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]); } for ($i = 0; $i < 100; $i++) { echo fm_get_filesize(pow('102'.rand(4, 100), $i))."\n"; }

preferences:
32.8 ms | 402 KiB | 5 Q