aboutsummaryrefslogtreecommitdiff
path: root/fn/fn.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-04-21 18:06:42 +0200
committervincent-peugnet <v.peugnet@free.fr>2018-04-21 18:06:42 +0200
commit5f2a948f5551f0c168e6572ba500724bddf4c576 (patch)
treec0e4563a3dac7eaf3e45508733dda0f0bb2e8888 /fn/fn.php
parentbf51c13452f7c38d7dc347bac8a6e9f2932532fb (diff)
downloadwcms-5f2a948f5551f0c168e6572ba500724bddf4c576.tar.gz
wcms-5f2a948f5551f0c168e6572ba500724bddf4c576.zip
V2 W V0 M
Diffstat (limited to 'fn/fn.php')
-rw-r--r--fn/fn.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/fn/fn.php b/fn/fn.php
index b075d57..65d14f4 100644
--- a/fn/fn.php
+++ b/fn/fn.php
@@ -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);
+}
?>