diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-04-21 18:06:42 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-04-21 18:06:42 +0200 |
commit | 5f2a948f5551f0c168e6572ba500724bddf4c576 (patch) | |
tree | c0e4563a3dac7eaf3e45508733dda0f0bb2e8888 /fn/fn.php | |
parent | bf51c13452f7c38d7dc347bac8a6e9f2932532fb (diff) | |
download | wcms-5f2a948f5551f0c168e6572ba500724bddf4c576.tar.gz wcms-5f2a948f5551f0c168e6572ba500724bddf4c576.zip |
V2 W V0 M
Diffstat (limited to 'fn/fn.php')
-rw-r--r-- | fn/fn.php | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -52,5 +52,30 @@ function search($haystack, $debut, $fin) } +function readablesize(int $bytes) +{ + + $num = 5; + $location = 'tree'; + $format = ' %d %s'; + + + + if ($bytes < 2 ** 10) { + $num = $bytes; + $unit = 'o'; + } elseif ($bytes < 2 ** 20) { + $num = round($bytes / 2 ** 10, 1); + $unit = 'Kio'; + } elseif ($bytes < 2 ** 30) { + $num = round($bytes / 2 ** 20, 1); + $unit = 'Mio'; + } elseif ($bytes < 2 ** 40) { + $num = round($bytes / 2 ** 30, 1); + $unit = 'Gio'; + } + + return sprintf($format, $num, $unit); +} ?> |