aboutsummaryrefslogtreecommitdiff
path: root/fn/fn.php
diff options
context:
space:
mode:
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);
+}
?>